[erlang-questions] Strange arithmetic behaviour
Richard A. O'Keefe
Mon May 12 03:35:05 CEST 2008
I wonder if the original poster wasn't a bit smarter than some of us
may have assumed. The existence of bignums in Erlang proves that a
language need not be limited by the deficiencies of the hardware.
ANSI Smalltalk provides "ScaledDecimal" numbers, which are numbers
with a fixed number of decimal places after the point but an
unbounded number before it. Maxima has bigfloats; source code can
be found at http://www.cs.berkeley.edu/~fateman/mma1.6/bf.lisp and
XEmacs lisp comes with them built in (see
Mathematica also has bigfloats. I have a vague recollection of
some Smalltalk having bigfloats, but cannot recall which (the ANSI
ScaledDecimal is great for money, not for trig.)
And of course Java has java.math.BigDecimal, described as
"Immutable, arbitrary-precision signed decimal numbers.
A BigDecimal consists of an arbitrary precision integer unscaled
value and a 32-bit integer scale."
The particularly interesting thing about BigDecimal is that it's
base 10. (High speed base 10 floating point hardware is shipping
now in the current generation of Power and zSeries machines...)
Base 10 bigfloats are particularly interesting as being likely to
give results non-programmers would expect rather more often than
limited precision base 2 floats do. But not ALL the time...
More information about the erlang-questions