[Chicago-talk] (no subject)
Michael Potter
michael at potter.name
Fri Apr 27 18:54:33 PDT 2012
Monks,
I am looking for a graceful way to round numbers.
The following program
#!/bin/perl
sub myround
{
my $src = shift;
printf("%.2f\n", $src);
}
myround("1.335");
myround("0.335");
outputs this:
$ perl ./round.pl
1.33
0.34
I know why. It has to do with the well known side effects of using
floating point.
What I don't know is a graceful way to round.
I would like to use something that already comes with perl and void
adding any modules.
--
potter
More information about the Chicago-talk
mailing list