Hi Guys, It's gotta be easy, but I can't find it... How do I reduce the number of decimal places in a variable ???
Simon
on Tue, May 07, 2002 at 10:30:22AM +0500, Simon wrote:
It's gotta be easy, but I can't find it... How do I reduce the number of decimal places in a variable ???
my $a = 3.141592; my $b = sprintf("%.02f", $a); $b += 2; print $b;
On Tue, 07 May 2002 11:01:54 xs@kittenz.org wrote:
on Tue, May 07, 2002 at 10:30:22AM +0500, Simon wrote:
It's gotta be easy, but I can't find it... How do I reduce the
number of
decimal places in a variable ???
my $a = 3.141592; my $b = sprintf("%.02f", $a); $b += 2; print $b;
Which will work, but personally I would try to avoid reducing the number of decimal places that are stored in the variable and instead do the reduction when the variable was printed, i.e. use sprintf and printf for printing the values.