News for hackers. Stuff that matters.
Re:A little thing to love about Perl 6 and COBOL by upofadown on Wednesday February 04, 2015 @08:03PM (#9001150)
The problem with using floating point to represent money has nothing to do with base 2. It is that money is generally treated as something countable. If you divide a dollar in thirds the resulting third of a cent is not exactly representable in base 10 either.
Re:A little thing to love about Perl 6 and COBOL by reikonomusha on Thursday February 05, 2015 @04:32AM (#9002388)
Base-2 is a problem in accounting because the written value doesn't always actually numerically equal what's being represented internally. With decimal, you don't have that problem, because we write in decimal.

The bigger problem however is how precision is "managed" with floats, which leads to things like non-associativity of operations.

Re:A little thing to love about Perl 6 and COBOL by upofadown on Thursday February 05, 2015 @08:15AM (#9003026)
The article suggested hardware BCD (packed decimals) was superior to floating point. That is true but not for the reason stated. The reason old time BCD was better was simply because they were treated at counting numbers (integers). If you use binary integers you get all of the same advantages with none of the serious headaches of BCD.
Re:A little thing to love about Perl 6 and COBOL by inglor on Thursday February 05, 2015 @05:03AM (#9002469)
Yes, but the way we write decimals doesn't represent numbers very easily, for example 10/3 can't be represented accurately with finite length decimals (but can with rationals)
Re:A little thing to love about Perl 6 and COBOL by ricardobeat on Thursday February 05, 2015 @06:50AM (#9002751)
Thus you'll never see anything being sold for "a third of a dollar". Accounting and finance have specific rules for rounding these, which can then be replicated with precision.
Re:A little thing to love about Perl 6 and COBOL by Roboprog on Thursday February 05, 2015 @10:49AM (#9003808)
Exactly - accountants count cents (or maybe mils), they do not measure/approximate them. If I buy 2 apples at 3 for a dollar, the cost gets normalized to cents before further adding up on the bill.

Self promotion: I've written about this topic before, and there is an aspect of trying to use fractions with relatively prime denominators that comes into play - http://roboprogs.com/devel/2010.02.html