Re: how to round off a decimal to the next whole number

2008-08-08 Thread Dr.Ruud
[EMAIL PROTECTED] schreef: > How do I round off a decimal to the next nearest whole digit , > example > 0.123 = 1, > 1.23 = 2, > 4.7312 = 5, etc etc. Define "next". You can use POSIX::ceil(), but then -1.23 becomes -1 and you might want -2 there? $ echo -1.23 4.1 5 |perl -MPOSIX -nwle'print

Re: how to round off a decimal to the next whole number

2008-08-06 Thread Rob Dixon
[EMAIL PROTECTED] wrote: > > How do I round off a decimal to the next nearest whole digit , > example > 0.123 = 1, > 1.23 = 2, > 4.7312 = 5, etc etc. > > Right now I can only do the above by extracting the first digit using splice > , then add one. You need the ceil() function from the POSIX

Re: how to round off a decimal to the next whole number

2008-08-06 Thread Jeff Pang
[EMAIL PROTECTED] 写道: > Hi, > How do I round off a decimal to the next nearest whole digit , > example > 0.123 = 1, > 1.23 = 2, > 4.7312 = 5, etc etc. $number = int($number) + 1; also does the same thing. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PR

Re: how to round off a decimal to the next whole number

2008-08-06 Thread Mr. Shawn H. Corey
On Wed, 2008-08-06 at 13:31 +0800, [EMAIL PROTECTED] wrote: > Hi, > How do I round off a decimal to the next nearest whole digit , > example > 0.123 = 1, > 1.23 = 2, > 4.7312 = 5, etc etc. > > Right now I can only do the above by extracting the first digit using splice > , then add one. > >

RE: how to round off a decimal to the next whole number

2008-08-06 Thread Stewart Anderson
> -Original Message- > From: Anirban Adhikary [mailto:[EMAIL PROTECTED] > Sent: 06 August 2008 06:51 > To: beginners@perl.org > Subject: Re: how to round off a decimal to the next whole number > > On Wed, Aug 6, 2008 at 11:01 AM, <[EMAIL PROTECTED]> wrote: &g

Re: how to round off a decimal to the next whole number

2008-08-05 Thread Anirban Adhikary
On Wed, Aug 6, 2008 at 11:01 AM, <[EMAIL PROTECTED]> wrote: > Hi, > How do I round off a decimal to the next nearest whole digit , > example > 0.123 = 1, > 1.23 = 2, > 4.7312 = 5, etc etc. > > Right now I can only do the above by extracting the first digit using > splice , then add one. > > Th