9999999999999999.0 – 9999999999999998.0
geocar.sdf1.org
9999999999999999.0 – 9999999999999998.0
1–10 of 274 posts
Re: 9999999999999999.0 – 9999999999999998.0
#2most popular previous discussion: https://news.ycombinator.com/item?id=10558871
Re: 9999999999999999.0 – 9999999999999998.0
#3Re: 9999999999999999.0 – 9999999999999998.0
#4Edit: Down-Voters go ahead and explain the LIE that is computer accuracy in the face of the linked demonstration. Computers, can't trust em.
Re: 9999999999999999.0 – 9999999999999998.0
#5Re: 9999999999999999.0 – 9999999999999998.0
#6Whenever I see these examples I do get annoyed st the Haskell one because we never are told what type it gets defaulted to, which only happens silently in the ghci repl, but will trigger a warning if it’s in a source file that’s being compiled.
Re: 9999999999999999.0 – 9999999999999998.0
#7DAE mind blown by imprecision in float arith? Edit: Down-Voters go ahead and explain the LIE that is computer accuracy in the face of the linked demonstration. Computers, can't trust em.
Floats are not decimals. That's unfortunately a really, really common misconception, owing in part to poor education. Developers reach for floats to represent decimals without thinking about the precision ramifications.
When you're working with decimals that don't need a lot of precision this doesn't generally come up (and naturally, those are the numbers typically used in textbooks). But when you start doing floating point arithmetic with decimals that require significant precision, things get bizarre very fast.
Unfortunately if a developer isn't expecting it, that's likely to happen in production processing code at a very inopportune time. But the computer is just doing what it's told - we have the tools to support safe and precise arithmetic with decimals that need it. It's a matter of knowing how and when to use floating point.
Re: 9999999999999999.0 – 9999999999999998.0
#8I'm a little concerned if merely knowing the existence of floating point arithmetic constitutes "prescience."
Re: 9999999999999999.0 – 9999999999999998.0
#92 with 64 bit floats, 0 with 32 bit floats.
Re: 9999999999999999.0 – 9999999999999998.0
#10DAE mind blown by imprecision in float arith? Edit: Down-Voters go ahead and explain the LIE that is computer accuracy in the face of the linked demonstration. Computers, can't trust em.
Thing is, a lot of people don't take CS courses, and have to learn this as they go along. More importantly, the naive cases all seem to work fine - it's only when you get to increasing precision / scales that you notice the cracks in the facade, and that's only if you have something that depends on the real accuracy (e.g. real world consequences from being wrong) or if someone bothers to go and check (using some other calculator that gives more precise results).
My own view on it is that it's past bloody time for languages to offer a fully abstracted class of real numbers with correct, arbitrary precision math - obviating the need for the developer to specify integer, float, long, etc. I don't mean that every language should act like this, but ones aimed at business software development, for example, would do well to provide a first-class primary number type that simply covers all of this properly.
Yes, I can understand that the performance will not be ideal in all cases, but the tradeoff in terms of accuracy, starting productivity, and avoiding common problems would probably be worth it for a pretty big subset of working developers.