Gossamer Forum
Home : General : Perl Programming :

help for meanings of round and pad

Quote Reply
help for meanings of round and pad
-------------------------------------------
$tmpprice = ($itemprice*$itemquant);
$tmpprice = round($tmpprice);
$tmpprice = pad($tmpprice);

---------------------------------------------

any help will be greatly appreciated.
Quote:
Quote Reply
Re: [floramate] help for meanings of round and pad In reply to
Round and Pad are sub-routines in the script where you pasted that code from.

Round() may consist of something like:

sub round {

return int($_[0]);

}

(Just a guess)

Last edited by:

RedRum: Sep 27, 2001, 5:07 AM
Quote Reply
Re: [RedRum] help for meanings of round and pad In reply to
Thank you very much RedRum. It do is a sub-routines.
--------
sub round {
my $number = shift;
$number = int($number * (10 ** 2) + .5) / (10 ** 2);
return $number;
}


sub pad {
my $number = shift;
if (index($number,".") >= 0) {
my($left,$right) = split(/\./,$number);
if (length($right) == 0) {
$number = $number . "00";
}
elsif (length($right) == 1) { $number = $number . "0"; }
}
else { $number = $number . ".00"; }
return $number;
}
Quote Reply
Re: [floramate] help for meanings of round and pad In reply to
Why on earth would someone write 10 ** 2 rather then 100?

Cheers,

Alex
--
Gossamer Threads Inc.