Repeating Decimal - Maple Help

Home : Support : Online Help : Mathematics : Number Theory : Repeating Decimal

NumberTheory

 RepeatingDecimal
 rational number in repeating decimal form

 Calling Sequence RepeatingDecimal(x) q := RepeatingDecimal(x) Sign(q) IntegralPart(q) NonRepeatingPart(q, output = o) RepeatingPart(q, output = o) convert(q, conversion) evalf(q) evalf[n](q)

Parameters

 x - rational number q - variable name to use for the returned object output = o - (optional) name; either list, rational, or float; defaults to list conversion - name; either rational or float n - positive integer

Description

 • The RepeatingDecimal(x) command computes the repeating decimal form of a rational number x. The return value is an object q that represents x exactly in decimal form. The object q can be used with the commands shown on this help page, but in order to use it with other commands you will typically need to convert it to a rational number or a floating-point number.
 • When q is displayed, if $\mathrm{interface}\left(\mathrm{prettyprint}\right)$ is greater than or equal to $2$, then the repeating part is denoted by a vinculum. Otherwise, the repeating part is delimited by a pair of parentheses.
 • The Sign command returns $1$ if q is positive and $-1$ if q is negative. If q is zero, then the return value is _Envsignum0 if it is assigned or $0$ if it is not assigned. (See signum)
 • The IntegralPart command returns the unsigned integer part of q.
 • The NonRepeatingPart command returns the non-repeating fractional part of q.
 • The RepeatingPart command returns the repeating part of q.
 • For NonRepeatingPart and RepeatingPart, if the keyword argument output is omitted or set to list, then the return value is a list of decimal digits that represents the corresponding part. If output is set to rational, then the return value is the rational number that represents the corresponding part. If output is set to float, then the return value is a floating-point number with the number of significant digits equal to the length of the non-repeating part or the length of the repeating part, depending on the command that was called.
 • The convert command can be used to convert q into either fractional form or a floating-point number.
 • evalf may also be used to convert q to a floating-point number. If evalf has an index n, then the output will have n significant digits.
 • Three operators, +, *, and ^ are defined for q. They can be used with other rational numbers in decimal or fractional form, and with floating-point numbers.
 • The equality operator = can also be used with q and will recognize equality among rational numbers in different forms and floating-point numbers representing terminating decimals or approximating repeating decimals.

Examples

 > $\mathrm{with}\left(\mathrm{NumberTheory}\right):$
 > $q≔\mathrm{RepeatingDecimal}\left(-\frac{191}{6}\right)$
 ${\mathrm{NumberTheory}}{:-}{\mathrm{RepeatingDecimal}}{}\left({-}\frac{{191}}{{6}}\right)$ (1)
 > $\mathrm{Sign}\left(q\right)$
 ${-1}$ (2)
 > $\mathrm{IntegralPart}\left(q\right)$
 ${31}$ (3)
 > $\mathrm{NonRepeatingPart}\left(q\right)$
 $\left[{8}\right]$ (4)
 > $\mathrm{NonRepeatingPart}\left(q,\mathrm{output}=\mathrm{rational}\right)$
 $\frac{{4}}{{5}}$ (5)
 > $\mathrm{NonRepeatingPart}\left(q,\mathrm{output}=\mathrm{float}\right)$
 ${0.8}$ (6)
 > $\mathrm{RepeatingPart}\left(q\right)$
 $\left[{3}\right]$ (7)
 > $\mathrm{RepeatingPart}\left(q,\mathrm{output}=\mathrm{rational}\right)$
 $\frac{{1}}{{30}}$ (8)
 > $\mathrm{RepeatingPart}\left(q,\mathrm{output}=\mathrm{float}\right)$
 ${0.03}$ (9)

A rational number in repeating decimal form can be converted back to fractional form.

 > $\mathrm{convert}\left(q,\mathrm{rational}\right)$
 ${-}\frac{{191}}{{6}}$ (10)
 > $\mathrm{convert}\left(q,\mathrm{float}\right)$
 ${-31.83333333}$ (11)
 > $q≔\mathrm{RepeatingDecimal}\left(\frac{1}{7}\right)$
 ${\mathrm{NumberTheory}}{:-}{\mathrm{RepeatingDecimal}}{}\left(\frac{{1}}{{7}}\right)$ (12)
 > $p≔\mathrm{RepeatingDecimal}\left(\frac{1}{3}\right)$
 ${\mathrm{NumberTheory}}{:-}{\mathrm{RepeatingDecimal}}{}\left(\frac{{1}}{{3}}\right)$ (13)
 > $\mathrm{evalf}\left[2\right]\left(p\right)$
 ${0.33}$ (14)
 > $p+q$
 ${\mathrm{NumberTheory}}{:-}{\mathrm{RepeatingDecimal}}{}\left(\frac{{10}}{{21}}\right)$ (15)
 > $\frac{1}{7}q$
 ${\mathrm{NumberTheory}}{:-}{\mathrm{RepeatingDecimal}}{}\left(\frac{{1}}{{49}}\right)$ (16)
 > ${q}^{2.5}$
 ${0.007713560679}$ (17)
 > $\mathrm{evalb}\left(p+q=10\mathrm{RepeatingDecimal}\left(\frac{1}{21}\right)\right)$
 ${\mathrm{true}}$ (18)
 > $\mathrm{evalb}\left(p=\frac{1}{3}\right)$
 ${\mathrm{true}}$ (19)
 > $\mathrm{evalb}\left(0.33333333333333=\frac{1}{3}\right)$
 ${\mathrm{true}}$ (20)
 > 

Compatibility

 • The NumberTheory[RepeatingDecimal] command was introduced in Maple 2016.