6 ms·
This is the type of thing that makes mathematicians flying tackle computer scientists. the CS: "Hey, it's round off error. Get used to it" the Mathematician:
by messel 16y ago
This is the type of thing that makes mathematicians flying tackle computer scientists.
the CS: "Hey, it's round off error. Get used to it"
the Mathematician: "Fix IT!!"
- xentronium 16y ago> This is the type of thing that makes mathematicians flying tackle computer scientists. Well, it's fixable. You lose your deal of performance in order to get some absolutely valid rational numbers representation. It's only that most tasks don't require this kind of precision.
- jules 16y agoAnd then you discover that you have a square root in your computation.
- xentronium 16y agoGood point, but rational numbers aren't closed under power/square root operation :)
- 3pt14159 16y agoEven then it doesn't matter fully. There are some languages with supported data types where you can actually write the equivalent of. x = 2 y = 2 1.upto 100 do x = x ** (1 / 2) end 1.upto 100 do x = x ** 2 end x == y # => true because it handles the math by only evaluating the operations at the very end.
- jules 16y agoWhich ones? It honestly seems unlikely to me that this would work well in practice.
- caf 16y agoIt's not "round off error", though. More like: "It's a base 2 fractional number with no exact decimal expansion with a finite number of digits. Display it in base 2 fractional form if you don't want to see an approximation."
- aliguori 16y agoWell, it's more like: Binary numbers are a countably infinite set. Decimal numbers are a countably infinite set. You can therefore map binary representation to decimal representation 1-1 with a simple mapping function. OTOH, floating point numbers are an uncountably infinite set. The only way to map binary numbers to floating point numbers is to map to a strict subset. The subset happens to be different when mapping binary to floating point and decimal to floating point when using IEEE754.
- mseebach 16y agoThe mathematician: That's fine for 22/7. Now, go fix your computer so it knows how to count to 0.3, kthxbye
- eru 16y agoAs a mathematician I do not value 0.3 above 22/7.
- caf 16y ago0.3 is a rational too, it's just 3/10. Anyway, mathematicians don't use numbers at all - debasing the equations by performing caculations with them is so.. gauche. Leave that to the physicists, chemists and engineers.
- eru 16y agoI saw the occasional number in my studies. We'd rather calculate with knows than numbers. (See http://en.wikipedia.org/wiki/Knot_theory http://en.wikipedia.org/wiki/Knot_theory)
- 16y ago
- DougBTX 16y agoWell, which data type would you like to store the value of PI in? I mean, you could re-calculate it to arbitrary precision every time you use it... just don't try to store it at "full" precision using floats or decimals.
- dagw 16y agoIf it where me I'd store the value of PI as a structure containing an IEEE double, a decimal representation of, say, 100 digits and a pointer to a function to that can evaluate PI to an arbitrary precision. Then I'd just just use PI as a symbol and do symbolic algebra for as long as possible. Don't evaluate it to anything until the user actually asks for a numeric representation. Once a numeric representation is required I'd pick a value from the above structure based on what has been asked for.