News for hackers. Stuff that matters.
Re:0.30000000000000004 by smitherfield on Sunday April 02, 2017 @04:31PM (#14018894)
My personal view is decimal arithmetic should be the default and floating-point should be the library in scripting languages. And probably also Java/C#/Go-type languages.
Re:0.30000000000000004 by richdougherty on Sunday April 02, 2017 @04:58PM (#14019009)
My personal view is that the programmer needs to know the difference because there are important tradeoffs to consider.

I do however think it should be easier to use decimal arithmetic. I've written financial apps in both Java and JavaScript and I wish both languages had native syntax and support for decimal numbers and arithmetic. JavaScript has nothing built-in and Java's BigDecimal class is clunky to use.

Re:0.30000000000000004 by adrianratnapala on Sunday April 02, 2017 @06:09PM (#14019329)
Decimal only takes care of a subset of cases. I.e. those where the source data nicely lines up in decimal. Good for finance (although I think Britain made a mistake when it gave up the old penny and the shilling). But even there, you sometimes have to divide by numbers like 12 and 365.

The point is NO representation is going to be idiot proof. So you just need to make a sufficient set of representations easy to use, and then try to teach the "idiots" what the underling issues are.

Re:0.30000000000000004 by int_19h on Monday April 03, 2017 @05:23PM (#14027281)
Decimal does only take care of a subset of cases, true. But 1) it's a very common subset, and 2) when it breaks down, people generally understand how and why, because they've dealt with it elsewhere.
Re:0.30000000000000004 by eru on Sunday April 02, 2017 @04:45PM (#14018948)
Why? Is decimal faster than arbitrary precision? If not, arbitrary precision should probably be the default (or binary).
Re:0.30000000000000004 by milesrout on Sunday April 02, 2017 @06:17PM (#14019371)
Nah, arbitrary-precision real arithmetic should be the default.