Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Why does the below give two different answers? The first usage returns the expected correct value (1), while the second returns 0. Perl 5.8.8 Win32.
Thanks in advance.
Very confused!
use strict; my $num=3891.0; my $answer=$num % 5; print "num is $num answer is $answer \n"; my $num=38.91 * 100; my $answer=$num % 5; print "num is $num answer is $answer \n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Modulus strangeness (%)
by ikegami (Patriarch) on Aug 30, 2007 at 17:34 UTC | |
|
Re: Modulus strangeness (%)
by dwm042 (Priest) on Aug 30, 2007 at 18:10 UTC |