FAQ: Difference between revisions

Jump to navigation Jump to search
28 bytes added ,  16 March 2021
(→‎How can I cite Octave?: Use shorter and real manual URL, fix BibTeX URL.)
Line 134: Line 134:
==Why is Octave's floating-point computation wrong?==
==Why is Octave's floating-point computation wrong?==


Floating-point arithmetic is an approximation '''in binary''' to arithmetic on real or complex numbers.  Just like you cannot represent 1/3 exactly in decimal arithmetic (0.333333... is only a rough approximation to 1/3), you cannot represent some fractions like <math>1/10</math> exactly in base 2.  In binary, the representation to one tenth is <math>0.0\overline{0011}_b</math> where the bar indicates that it repeats infinitely (like how <math>1/6 = 0.1\overline{6}_d</math> in decimal).  Because this infinite repetition cannot be represented exactly with a finite number of digits, rounding errors occur for values that appear to be exact in decimal but are in fact approximations in binary, such as for example how 0.3 - 0.2 - 0.1 is not equal to zero.
Floating-point arithmetic is an approximation '''in binary''' to arithmetic on real or complex numbers.  Just like you cannot represent 1/3 exactly in decimal arithmetic (0.333333... is only a rough approximation to 1/3 for any finite number of 3s), you cannot represent some fractions like <math>1/10</math> exactly in base 2.  In binary, the representation to one tenth is <math>0.0\overline{0011}_b</math> where the bar indicates that it repeats infinitely (like how <math>1/6 = 0.1\overline{6}_d</math> in decimal).  Because this infinite repetition cannot be represented exactly with a finite number of digits, rounding errors occur for values that appear to be exact in decimal but are in fact approximations in binary, such as for example how 0.3 - 0.2 - 0.1 is not equal to zero.


In addition, some advanced operations are computed by approximation and there is no guarantee for them to be accurate, see [https://en.wikipedia.org/wiki/Rounding#Table-maker.27s_dilemma Table-maker's dilemma] for further references. Their results are system-dependent.
In addition, some advanced operations are computed by approximation and there is no guarantee for them to be accurate, see [https://en.wikipedia.org/wiki/Rounding#Table-maker.27s_dilemma Table-maker's dilemma] for further references. Their results are system-dependent.
Anonymous user

Navigation menu