convert.decimal.fraction.to.nary | R Documentation |
A function to convert a decimal fraction into its base-n (n-ary) representation.
convert.decimal.fraction.to.nary(d, e, base, ndigits = 54)
d |
the integer part of the decimal fraction. |
e |
the exponent for 10^(-e) |
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:** d, e, 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 = 1/10^1
convert.decimal.fraction.to.nary(1, 1, base = 2)
# Trinary expansion of 1/10 = 1/10^1
convert.decimal.fraction.to.nary(5, 1, base = 3)
# Base-5 expansion of 1/5 = 2/10^1
convert.decimal.fraction.to.nary(2, 1, base = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.