On Wed, Apr 05, 2000 at 03:42:51PM +1000, Nigel Maddock wrote:
> On Wed, Apr 05, 2000 at 03:31:41PM +1000, Conrad Parker wrote:
> > On Wed, Apr 05, 2000 at 03:04:06PM +1000, [EMAIL PROTECTED] wrote:
> > >
> > > Basically I don't want decimal points in the final output.
> > >
> >
> > using printf: printf "%.0f\n", $data1;
> >
> > you can also take the floor or ceil of your variables with
> > POSIX::floor and POSIX::ceil.
> >
> > for more info:
> > perldoc -f printf
> > perldoc POSIX
>
> int()
>
yeah, I was avoiding that; the docs say not to use it ...
conrad@fligje:~$ perldoc -f int
int EXPR
int
Returns the integer portion of EXPR. If EXPR is omitted, uses $_.
You should not use this function for rounding: one because it truncates
towards 0, and two because machine representations of floating point
numbers can sometimes produce counterintuitive results. For example,
int(-6.725/0.025) produces -268 rather than the correct -269; that's
because it's really more like -268.99999999999994315658 instead. Usually,
the sprintf(), printf(), or the POSIX::floor and POSIX::ceil
functions will serve you better than will int().
--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to [EMAIL PROTECTED] with
unsubscribe in the text