Here is something directly from the Perl Cookbook (Ram).
FYI - The O'Reilly Perl CD Bookshelf is a valuable reference source. It
has 6 Perl books on 1 CD with an index for all books.
Chapter 2
Title: Re: Rounding numbers
use POSIX;
$ceil = ceil(3.5); # 4
>From perlfaq4.
-Original Message-From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Alloun, JonathanSent: Wednesday, February 14, 2001 6:54
AMTo: [EMAIL PROTECTED]Subj
- Original Message -
From: "Morbus Iff" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, February 14, 2001 7:07 AM
Subject: Re: Rounding numbers
> >Is there a function out there that will enable me to round up a
number
> >i.e. 0.9349595
> "Alloun, Jonathan" wrote:
>
> Hello,
>
> Is there a function out there that will enable me to round up a number
>
> i.e. 0.93495959 would become 1
use strict;
use POSIX;
for (0.93495959, 1.91, 2.01) {
print ceil ($_), "\n";
}
__END__
--
,-/- __ _ _ $Bill Luebke
At 11:53 AM 2/14/01 -, Alloun, Jonathan wrote:
>
> Hello, Is there a function out there that will enable me to round up a
>number i.e. 0.93495959 would become 1 Thanks in advance,
Jonathan
Not as short as a simple function call, but works:
$x = 2.01;
$y = ($x == int($x) ?
>Is there a function out there that will enable me to round up a number
>i.e. 0.93495959 would become 1
I've got this one that will allow you to round to tens, hundreds, and
thousands:
##
# round() - rounds a number