awohld has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; my $num = 5.8687; my ( $int, $float ) = split '.', $num; #$float = 5 if $float > ?; #$float = 0 if $float < ?; # example should print '5.5' print $int . '.' . $float . "\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Round down to '.5' or '.0'
by gamache (Friar) on Oct 24, 2007 at 18:29 UTC | |
by ikegami (Patriarch) on Oct 24, 2007 at 18:50 UTC | |
by gamache (Friar) on Oct 24, 2007 at 18:55 UTC | |
by ikegami (Patriarch) on Oct 24, 2007 at 19:10 UTC | |
| |
by oha (Friar) on Oct 25, 2007 at 09:41 UTC | |
by awohld (Hermit) on Oct 24, 2007 at 20:06 UTC | |
by ikegami (Patriarch) on Oct 24, 2007 at 20:10 UTC | |
by Nkuvu (Priest) on Oct 25, 2007 at 19:33 UTC | |
Re: Round down to '.5' or '.0'
by moritz (Cardinal) on Oct 24, 2007 at 18:30 UTC | |
by gamache (Friar) on Oct 24, 2007 at 18:43 UTC | |
Re: Round down to '.5' or '.0'
by toolic (Bishop) on Oct 24, 2007 at 18:32 UTC |