Timeline for Is floating point math broken?

Current License: CC BY-SA 3.0

25 events
when toggle format what by license comment
Dec 31, 2021 at 1:45 comment added Stephen C Yea ... but the kids will still argue about who got the bigger slice :-)
Oct 25, 2017 at 8:54 comment added philipxy A one-foot-diameter ie one-metre-circumference pizza halved 53 times gives a slice roughly the width of an electron. (Now I feel like I know how big that that last bit is.)
Dec 11, 2016 at 18:02 comment added Edgar Klerks @ShadowRanger Haskell does include rational numbers as library, it is not built into the base language. (See Data.Ratio for the implementation)
May 20, 2016 at 7:58 comment added liudongmiao I think should ommit 0.3000000000000000444089209850062616169452667236328125. Just say 0.1000000000000000055511151231257827021181583404541015625 + 0.200000000000000011102230246251565404236316680908203125 = 0.3000000000000000166533453693773481063544750213623046875, which is 0.0100110011001100110011001100110011001100110011001100111, and the last bit should be ommit, so it's the same with 0.010011001100110011001100110011001100110011001100110100, which is 0.3000000000000000444089209850062616169452667236328125.
Feb 3, 2016 at 18:57 comment added ShadowRanger (2/2)...and others, like C/C++ have well known, commonly used third party libraries like GMP/MPFR that add the same features to the language (in the case of C++ and GMP/MPFR, with modern C++ standards that add constexpr, r-value references, and auto for type deduction, the integration is so tight that you can use mpfr_class as a drop in replacement for a primitive type like double. PHP is unusual in that it provides no rational support, I can't even find third party libs for it. And since it lacks operator overloading, add-on types wouldn't be drop in replacements in any event.
Feb 3, 2016 at 18:54 comment added ShadowRanger @ChrisJester-Young: Saying "very few mainstream programming languages have rational numbers built-in" as a counter to "Except PHP. It doesn't know any better." is a little misleading. While few languages outside a few functional languages with limited industry use (e.g. Lisp, Haskell) offer built-in, library-free rational numbers with complete language integration equivalent to that of integers, many languages, particularly PHP competitors like Perl, Python and Ruby ship with a rational number library that can be used like a built-in type after import... (1/2)
Dec 10, 2015 at 5:34 comment added Tanin I don't quite understand. I thought 0.1000000000000000055511151231257827021181583404541015625 and 0.200000000000000011102230246251565404236316680908203125 is already rounded to 53-bit mantissa. I'm not sure why we round to 53-bit mantissa again. Could you point me to how it works? Thanks!
Dec 10, 2015 at 5:13 comment added Chris Jester-Young @Tanin It is if you round the result to double-precision (53-bit mantissa) afterwards. If you use an arbitrary-precision calculator, like the one you linked to, of course you'll get different results.
Dec 10, 2015 at 5:11 comment added Tanin I just tried and 0.1000000000000000055511151231257827021181583404541015625 + 0.200000000000000011102230246251565404236316680908203125 is not equal to 0.3000000000000000444089209850062616169452667236328125 (ttmath.org/online_calculator)
Dec 6, 2015 at 5:47 comment added jeremy radcliff Very nice explanation, it helped me a lot. Formalism is always good once you develop some intuition.
Aug 13, 2015 at 14:51 comment added Chris Jester-Young @connexo Also, "every idiot" can't rotate a pizza exactly 36 degrees. Humans are too error-prone to do anything quite so precise.
Aug 13, 2015 at 14:50 comment added Chris Jester-Young @connexo Okay. How would you program your pizza rotator to get 36 degrees? What is 36 degrees? (Hint: if you are able to define this in an exact fashion, you also have a slices-an-exact-tenth pizza cutter.) In other words, you can't actually have 1/360 (a degree) or 1/10 (36 degrees) with only binary floating point.
Aug 13, 2015 at 14:09 comment added connexo If you feel that this doesn't work because processors and programming languages cannot do to 1 what every idiot can do to a pizza (that is, rotate it), maybe you get an idea why explaining complex mathematical problems with every day examples usually doesn't work :)
Aug 13, 2015 at 14:02 comment added connexo The precision pizza cutter would have to be complemented by a precision pizza rotator. To get exactly 1/10 of a pizza, proceed as follows: Take the full pizza and cut it in half. Keep the pizza cutter in place and rotate the pizza exactly 36 degrees, and let the pizza cutter do the exactly same cut as in step 1. Easy peasy!
Mar 18, 2015 at 20:25 comment added Arne Babenhauserheide @Aidiakapi by harnessing something like scmutils, you could use prior simplification, so if you wrote something as (* 5 pi) and used that in an equation, the muiltiplication with pi would be done last, minimizing the loss of precision. See cs.rochester.edu/~gildea/guile-scmutils — this is symbolic math, then: Simplifying the equation before calculating anything.
Mar 11, 2015 at 13:06 comment added Aidiakapi @ArneBabenhauserheide I think it's worth adding that this will only work with rational numbers. So if you're doing some math with irrational numbers like pi, you'd have to store it as a multiple of pi. Of course, any calculating involving pi cannot be represented as an exact decimal number.
Dec 17, 2014 at 23:08 audit First posts
Dec 17, 2014 at 23:09
Dec 6, 2014 at 2:10 audit First posts
Dec 6, 2014 at 2:10
Dec 5, 2014 at 9:15 audit First posts
Dec 5, 2014 at 9:16
Nov 28, 2014 at 17:20 audit First posts
Nov 28, 2014 at 18:08
Nov 25, 2014 at 16:56 comment added Chris Jester-Young @FloatingRock Actually, very few mainstream programming languages have rational numbers built-in. Arne is a Schemer, as I am, so these are things we get spoilt on.
Nov 22, 2014 at 4:44 history edited Chris Jester-Young CC BY-SA 3.0
Yes, some languages provide decimal floating point, but it's uncommon and you usually have to specifically request it.
Nov 20, 2014 at 13:24 history edited Chris Jester-Young CC BY-SA 3.0
Change Quora link to avoid regwall (hopefully).
Nov 20, 2014 at 6:40 comment added Arne Babenhauserheide Note that there are some languages which include exact math. One example is Scheme, for example via GNU Guile. See draketo.de/english/exact-math-to-the-rescue — these keep the math as fractions and only slice up in the end.
Nov 20, 2014 at 2:39 history answered Chris Jester-Young CC BY-SA 3.0