ShortRational.mesa
Michael Plass, May 2, 1984 10:40:13 am PDT
ShortRational:
CEDAR
DEFINITIONS
=
BEGIN
Rational:
TYPE
~
RECORD
[numerator:
INTEGER
, denominator:
CARDINAL
];
FromReal
:
PROC
[real:
REAL
]
RETURNS
[Rational];
picks a close rational approximation for the real number.
denominator will be zero for out-of-range inputs.
answer is always in lowest terms.
END
.