News for hackers. Stuff that matters.
Re:Papers and essays that every programmer should be aware of by nraynaud on Saturday June 29, 2013 @07:37PM (#5964101)
I don't know why "what every computer scientist should know about floating-point arithmetic" is not in here. Ruby or the last framework are just fads, but IEEE754 is here to stay and nobody know how to use it (and I never remember the details myself, I'm always struggling).
Re:Papers and essays that every programmer should be aware of by bdg on Saturday June 29, 2013 @07:59PM (#5964160)
I like to tell IEEE754 as an improvised story, because it's so rich in history as far as data types go.

They were first introduced in 1941 on the German made Z3 compuer. Whic means, yup, we can blame nazis for 0.1+0.2 == 0.30000000000000004

In all seriousness, more programmers need to understand this. I've seen more than a few beginners go rant about how awesome their language X is when contrast against language Y because language Y has bugs like 0.1+0.2 ... then they're blown away when the see their language too has the same "bug".

Re:Papers and essays that every programmer should be aware of by dragonwriter on Saturday June 29, 2013 @10:00PM (#5964410)
Scheme programmers don't have that problem, because Scheme is one of the few languages that does math in a sane manner. The whole inexact-by-default behavior of most languages with literals expressed as decimals is somewhat nutty.

For all the flexibility provided by Scheme's structure (shared with other lisps), the thing I wish more languages would borrow from scheme is the numerical tower, which doesn't need Lispish syntax or any of the other features of Scheme that most people object to.

Re:Papers and essays that every programmer should be aware of by nraynaud on Saturday June 29, 2013 @10:32PM (#5964480)
I think it's a bit naïve, because transcendental number have no exact finite representation in any integral base. Having arbitrary precision helps only in some cases.
Re:Papers and essays that every programmer should be aware of by dragonwriter on Saturday June 29, 2013 @11:05PM (#5964533)
Having arbitrary precision helps in all the cases where you start with something given as an exact decimal, and perform only operations which produce exact decimal outputs from exact decimal inputs, which isn't a particularly small set of use cases. Scheme's approach of using exact representations unless either an inexact one is explicitly requested or an operation is used which produces a result which has no exact representation is correct in the broadest number of cases at the expense if requiring a tiny bit of extra effort to exchange accuracy for efficiency where that is desired.

This is, IMO, clearly the best approach for a general purpose language, and far superior to the large number of languages which lack even a convenient syntax for exact decimal literals.

Re:Papers and essays that every programmer should be aware of by thetwiceler on Sunday June 30, 2013 @09:15AM (#5965660)
I totally agree. Unless we decide to leave the field of rational numbers (with exponents, trigonometrics or nth roots), there's little reason not to keep the exact rational number around.

Fortunately Haskell does this too with Data.Ratio!

Re:Papers and essays that every programmer should be aware of by nraynaud on Saturday June 29, 2013 @08:08PM (#5964185)
frankly I don't really understand it. I mean we do real geeky numerical computations only once in a while for a week, and then we spend a few months on CSS IE compatibility. I never remember what kind of computations break my numbers in what ways and how I know if I can safely use == or not in my case (and if I can't, how big the epsilon should be).
Re:Papers and essays that every programmer should be aware of by mynegation on Saturday June 29, 2013 @08:21PM (#5964208)
Oh, with == it is pretty simple: do not _ever_ use it on floating point data.
Re:Papers and essays that every programmer should be aware of by nraynaud on Saturday June 29, 2013 @08:28PM (#5964227)
go read the paper.