3 ms·
It is never possible to represent all the numebr in a fixed length binary string.
by akshar200 17y ago
It is never possible to represent all the numebr in a fixed length binary string.
- SapphireSun 17y agoYou can still store a symbolic representation of those numbers that you can't represent though in limited cases (such as rational division) and write your algorithms so that it doesn't truncate it in the worst possible way.
- wingo 17y agoI feel compelled to mention that you could just use a language with a proper numeric tower. If the numbers that you input to an algorithm are exact, you get an exact answer. If they are inexact, you get an inexact answer. 399 999 999 999 999 is an exact number. guile> (- 399999999999 399999999998) $1 = 1
- tl 17y ago~$ sbcl * (- 399999999999999 399999999999998) 1 * (- 12.52 12.51) 0.010000229 * (* 850 77.1) 65535.0
- cousin_it 17y agoAnother intriguing possibility is to represent all required numbers exactly, even sqrt(2). It is possible with lazy evaluation: essentially a number is represented by a function that computes the digits of its decimal expansion, and arithmetic operations take two functions and return a third. Inefficient but mind-blowing.