juo has asked for the wisdom of the Perl Monks concerning the following question:
Does anybody know how to perform roundings but at the same time convert integers to float using the rounding parameters. I have been using Math::Round for that purpose however it does not add zeroes. See example below.
#!/perl/bin -w use strict; use Math::Round; # Not standard with Perl delivered my @number = qw(3 3.555 3.222334 3.4 1 0); for my $float(@number) { $float = nearest(.001, $float); print "$float\n"; } __END__ Result of Math::Round 3 3.555 3.222 3.4 1 0 This is what I want to get 3.000 3.555 3.222 3.400 1.000 0.000
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to round and keep floating digits
by Zaxo (Archbishop) on Oct 09, 2002 at 21:16 UTC | |
Re: How to round and keep floating digits
by BrowserUk (Patriarch) on Oct 09, 2002 at 21:18 UTC | |
by Anonymous Monk on Mar 12, 2008 at 21:13 UTC |