R
RobertMaas
From: Tor Iver Wilhelmsen said:Perhaps some future format will represent numbers as a/b instead of
as the current a*2^b
Future?? LISP has had that, namely ratios of integers, for many years.
So instead of typing -0.07 and 0.0175 you type -7/100 and 175/10000.
It would be trivial to write a Java class RatioBigInteger which is
based upon the BigInteger class. You get exact answers if you always
start with ratios of integers such as those, and the only operations
you perform are the four basic ones (+ - * /), but as soon as you do
square root or trigonometric etc. the result can't be represented as
exact ratios of integers so you're stuck again.
IMO, the right thing is to use interval arithmetic. Whenever the answer
can't be expressed exactly in the particular representation, you get an
interval expressing lower and upper bound. These intervals would be
carried through the whole chain of calculations, then when you're ready
to output the final result you can use the bounds to determine how many
digits are accurate enough to be worth printing, or you can do that
plus also represent the next digit by a range. For example, if you
tried to do the 1/3 * 3 calculation, converting to range of decimal
fractions for printing, you'd get successively:
0.3333333333[3..4]
0.9999999999[9..C] (using hexadecimal notation for digits larger than 9)
or if you allowed negative digits (using J K ... for -1 -2 ...):
1.0000000000[J..2]
(Oldtimers may recognize J K ... as Hollerith keypunch codes for zone
minus combined with digit 1 2 ... in same column.)