numlib::decimal
-- infinite
representation of rational numbersnumlib::decimal
(q)
computes the decimal
expansion of a rational number q
.
numlib::decimal(q)
q |
- | nonnegative rational number |
numlib::decimal
(q)
returns an expression
sequence consisting of nonnegative integers or an expression sequence
consisting of nonnegative integers and terminated by a list of
nonnegative integers.
q
is a nonnegative rational number whose decimal
expansion is finite, then numlib::decimal
(q)
returns the expression sequence starting with the integral part of
q
and followed by the digits after the decimal point.q
is a nonnegative rational number whose decimal
expansion is infinite, then
numlib::decimal
(q)
returns the expression
sequence starting with the integral part of q
, followed by
the digits of the pre-period and terminated with a list, containing the
digits of a minimal period.numlib::decimal
returns an error if the argument is a
number but not a rational number .Computing the decimal expansion of :
>> numlib::decimal(1999)
1999
Computing the (finite) decimal expansion of :
>> numlib::decimal(52187/78125)
0, 6, 6, 7, 9, 9, 3, 6
Computing the (infinite) decimal expansion of :
>> numlib::decimal(111/7)
15, [8, 5, 7, 1, 4, 2]
Computing the (infinite) decimal expansion of :
>> numlib::decimal(37/28)
1, 3, 2, [1, 4, 2, 8, 5, 7]