in reply to Re^3: Getting different results with $var++ and $var += 1
in thread Getting different results with $var++ and $var += 1
It really makes me wonder why we persist in using binary floating point for decimal arithmetic !Well, it really make me wonder why programming languages (and OSses) have no problem using layers up layers, yet still let their basic datatypes be determined by the hardware the machine is running on.
Take Perl for instance. It provides (almost unlimited sized) strings as a basic data type, despite strings not being native to the hardware, or even a basic type in C. It doesn't force the programmer to cast numerical values between integers, longs, floats or doubles. It prides itself it takes care of gritty details and doesn't bother the programmer with it.
If if a programmer is surprised that '0.84 - 0.34 == 0.5' isn't true, we scold at him, for being an ignorant person, not knowing the internal hardware representation of the data.
IMO, that sucks. If I wanted to program in such a way that I have to consider the internal hardware representation, I can code in C. I wish Perl had arbitrary precision integers, and could add/subtract/compare decimal numbers without losing precision.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Getting different results with $var++ and $var += 1
by gone2015 (Deacon) on Dec 04, 2008 at 09:23 UTC | |
by Corion (Patriarch) on Dec 04, 2008 at 09:26 UTC | |
by gone2015 (Deacon) on Dec 04, 2008 at 10:50 UTC |