in reply to Reading wrong value from excel sheet
what every programmer should know about floating point
IIRC, unless the denominator of your fraction is able to be represented as sums of 1/2**N (mlx: clarified) (1/2 + 1/8, for example), you end up with an approximation of the value. Many times, this tends to be "close enough". If dealing with money, for example, you will often want to use some other representation than floating point under the hood (an integer representation of millicents or some such comes to mind).
An example REPL - perl -ne 'printf("%.60f\n", $_)'.
Repost of Re: Unexpected results when storing a Math::Round nearest value in MongoDB
Update: See My floating point comparison does not work. Why ? for more information
Update 2: Clarified after apparent confusion
--MidLifeXis
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reading wrong value from excel sheet
by locked_user sundialsvc4 (Abbot) on May 21, 2013 at 19:59 UTC | |
by MidLifeXis (Monsignor) on May 21, 2013 at 20:02 UTC | |
by choroba (Cardinal) on May 21, 2013 at 20:45 UTC |