If you ask a programming language to calculate 0.6 + 0.7, you’ll get something like 1.2999998, and that’s because of how floating point numbers are represented in computers. But if you ask a calculator, or even the calculator app on your phone, to do the same thing, it will give you the correct answer: 1.3. Why? Do calculators not represent floats the same way that other computers do?
Computer Science – How Do Calculators Represent Floating Points Perfectly?
calculatorcomputer sciencefloating point
Related Question
- [Math] Is $\tan^{-1}$ for $\arctan$ on the calculator wrong
- [Math] A nice way to do Euler’s method on a calculator
- [Math] Calculate the total number of floating-point numbers in a certain range
- 0.1+0.2=0.30000000000000004 in floating point IEEE representations arithmetic addition manual proof.
- Complex floating point types
- Is There Any Good Way of Checking Floats for Approximate Equality
Best Answer
The short version is, they're cheating. Calculators or calculator apps are, if anything, less capable than computers and programming languages in general. That said, they're also specialized for doing exactly that sort of thing, so they're more inclined to take 12.9999998 and round it for you to 13. Programming languages will do the same thing, but depending on which language and how precise the number, you might have to ask them to.
Take any calculator and try something like adding $1+10^{-100}-1$, and in my experience, you'll get $0$, not $0.0000\dots 001$.