Infinite representation of rational numbers
MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
numlib::decimal(q
)
numlib::decimal(q)
computes the decimal
expansion of a rational number q
.
If 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.
If 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 preperiod and terminated with a list,
containing the digits of a minimal period.
Computing the decimal expansion of 1999:
numlib::decimal(1999)
Computing the (finite) decimal expansion of :
numlib::decimal(52187/78125)
Computing the (infinite) decimal expansion of :
numlib::decimal(111/7)
Computing the (infinite) decimal expansion of :
numlib::decimal(37/28)

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.