in reply to $var == 1 fails when $var = 1
DB<8> printf '%.20f', 0.688 + 0.289 + 0.023 0.99999999999999989000
so $var != 1
Perl's DWIM is sometimes trying to round the string representation, that's why eq seemingly "works".
Rule of thumb, add integers and correct afterwards to the right magnitude.
DB<15> p 1 == (688 + 289 + 23) /1000 1
see also Humans have too many fingers
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: $var == 1 fails when $var = 1
by mjlush (Novice) on Sep 20, 2018 at 15:23 UTC | |
by LanX (Saint) on Sep 20, 2018 at 15:33 UTC | |
by mjlush (Novice) on Sep 20, 2018 at 15:40 UTC | |
by syphilis (Archbishop) on Sep 21, 2018 at 02:07 UTC | |
by LanX (Saint) on Sep 20, 2018 at 15:43 UTC |