News for hackers. Stuff that matters.
Re:Flaky: datatypes for real world quantities by GhotiFish on Sunday May 19, 2013 @01:13AM (#5731906)
floating point will never be obsolete, it is a log scale datatype, and log scale datatypes represent most natural values perfectly.

The only place where the shoe doesn't fit is where you need a minimum accuracy. In that case what you should be doing is using integers to represent your minimum quantifiable unit.

For example, you could represent currency in millicents to give you respectably accurate rounding. Not accurate enough? Microcents then. Now you don't have enough range? Good, you're thinking about your requirements now, floating point DEFINITELY wouldn't of worked.

Re:Flaky: datatypes for real world quantities by qznc on Sunday May 19, 2013 @04:39AM (#5732276)
In addition you must prevent overflows.

Microcents with signed long long (64bit) means a maximum value of 263 / 100 / (106) = 92233720368. In words "92 billion", which might not be enough.

Re:Flaky: datatypes for real world quantities by reeses on Sunday May 19, 2013 @11:21AM (#5733090)
In environments with exhaustive partitions and automatic 'promotion' (i.e., Common Lisp but probably not Ruby, etc.), your overflow would result in a correctly calculated bignum.
Re:Flaky: datatypes for real world quantities by GhotiFish on Sunday May 19, 2013 @08:35AM (#5732699)
yup! Which is scary to think about, because if you had a microcents requirement for accuracy, your ceiling would of being at 2^53/2*(micro) = 4,503,599,627

4 billion. eak.

Re:Flaky: datatypes for real world quantities by reeses on Sunday May 19, 2013 @11:13AM (#5733049)
Integers, BCD, rationals, or other arbitrary precision representations are preferable as well. IBM keeps BCD alive and fast for COBOL and other 'legacy' systems.