Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
It prints:my $x = 125; my $l = log($x) / log(5); print "LOG == $l\n"; print "int(LOG) == ", int($l), "\n"; print "Are equal: ", ($l == int($l)) ? "true\n" : "false\n";
For $x = 25 it works as expected, but for $x = 125 (and probably other numbers), it acts really weird. It says that 3 != int(3). I'm wondering how is this possible... Is there some explanation for this?LOG == 3 int(LOG) == 3 Are equal: false
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: log() and int() problem
by moritz (Cardinal) on Dec 25, 2012 at 17:02 UTC | |
by Anonymous Monk on Dec 25, 2012 at 21:35 UTC | |
by Anonymous Monk on Dec 25, 2012 at 23:17 UTC | |
|
Re: log() and int() problem
by toolic (Bishop) on Dec 25, 2012 at 17:02 UTC | |
|
Re: log() and int() problem
by LanX (Saint) on Dec 25, 2012 at 17:17 UTC | |
by dave_the_m (Monsignor) on Dec 25, 2012 at 18:34 UTC | |
by LanX (Saint) on Dec 25, 2012 at 18:49 UTC | |
by Anonymous Monk on Dec 25, 2012 at 21:03 UTC | |
by eyepopslikeamosquito (Archbishop) on Dec 25, 2012 at 22:40 UTC | |
by LanX (Saint) on Dec 25, 2012 at 23:19 UTC | |
by LanX (Saint) on Dec 25, 2012 at 21:11 UTC |