>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 to the specified degree #
##############################################################################
# NOTES: #
# Rounds a given number to the specified degree. #
# If no number specified, round down. #
# #
# USAGE: #
# &round(12344.55) #returns 12344 #
# &round(12344.55, 1) #returns 12345 #
# &round(12344.43, 10) #returns 12340 #
# &round(12345.42, 100) #returns 12300 #
# &round(12432.78, 1000) #returns 12000 #
##############################################################################
sub round {
# gather our data, and set defaults.
my ($result); my ($number,$round_how) = @_;
$round_how = 0 unless $round_how;
# bah! uhhh... we do magical stuff here.
if ($round_how) {
$number /= $round_how;
if (int($number * 2) == (int($number) * 2) + 1) {
$result = (int($number) + 1) * $round_how;
}
else { $result = int($number) * $round_how; }
}
# just round down.
else { $result = int($number); }
return $result;
}
1;
--
Morbus Iff
Here we have One DimensionalMorbus - Flatter than
_____ Brooke Shields, able to to be ignored for days at a time,
slower than a Microsoft Slug. Defender of AOL users, Bill
Gates and other one dimensional life forms who mutter
"I don't get it..."
-03--- <\/> ---- <http://www.disobey.com/> --- Bad Ascii, Short Notice ----
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users