convert.rational.fraction.to.nary | R Documentation |
A function to convert a rational fraction into its base-n (n-ary) representation.
convert.rational.fraction.to.nary(p, q, base, ndigits = 1000)
p |
the numerator of the rational fraction |
q |
the denominator of the rational fraction |
base |
the base for the n-ary representation of the decimal fraction |
ndigits |
the maximum number of digits to search for the repeating pattern |
See
http://cs.furman.edu/digitaldomain/more/ch6/dec_frac_to_bin.htm
for more details.
**NOTE:** p, q, and base should be **integer type**, i.e. suffixed with an 'L'.
If not, they will be coerced to integer type if possible.
# Binary expansion of 1/10
convert.rational.fraction.to.nary(1, 10, base = 2)
# Base-5 expansion of 1/3
convert.decimal.fraction.to.nary(1, 3, base = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.