elfpen has asked for the wisdom of the Perl Monks concerning the following question:
$i = -53.80; $j = 46.70; $k = $i + $j; printf "i $i j $j k $k\n"; --- output --- i -53.8 j 46.7 k -7.09999999999999There's no multiplication or division. I'm able to get around it by using
sprintf "%.2f", $k;But it did catch me by surprise.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Bad math
by Marshall (Canon) on Oct 31, 2011 at 15:04 UTC | |
|
Re: Bad math
by davido (Cardinal) on Oct 31, 2011 at 16:06 UTC | |
by rgiskard (Hermit) on Nov 02, 2011 at 04:45 UTC | |
|
Re: Bad math
by moritz (Cardinal) on Oct 31, 2011 at 15:08 UTC | |
|
Re: Bad math (tweak)
by tye (Sage) on Oct 31, 2011 at 17:22 UTC | |
by ikegami (Patriarch) on Dec 01, 2011 at 23:39 UTC | |
by tye (Sage) on Dec 01, 2011 at 23:44 UTC |