Is .2 irrational?

Gary M. Samuelson garys at bunker.UUCP
Fri Jan 9 04:59:12 AEST 1987


In article <568 at brl-sem.ARPA> ron at brl-sem.ARPA (Ron Natalie <ron>) writes:
>In article <1384 at bunker.UUCP>, garys at bunker.UUCP (Gary M. Samuelson) writes:
>> A floating point format could
>> be designed which allowed exact representation of all decimal fractions,
>> up to some number of places precision.
>
>Gee, how do you deal with 1/3?  I'm not sure how I do that even on
>a decimal computer.  Perhaps you meant that can handle an exact represntation
>of all fractions of the form INTEGER/(Power of 10)

I did say "up to some number of places precision," which I think covers
your objection to my imprecise wording.

But if you really want:  Define a floating point number as a triple of
integers (Numerator, Denominator, Exponent).  Let this represent the
number (N/D) * B ** E, where B is a constant (e.g., 10).  In normalized
form, N and D have no common factors, and neither N nor D is divisible by B.
As a special case, define (0, 0, 0) to represent zero.

Formal analysis of this scheme, including proofs that each representable
number would have a unique normalized form, or that its arithmetic
would be well defined, is left as an exercise to the reader.  (However,
if someone wants to pay my living expenses while I pursue this line of
research, let me know :-).

Gary Samuelson



More information about the Comp.lang.c mailing list