convert.decimal.fraction.to.binary | R Documentation |
A function to convert a decimal fraction into a binary fraction, for demonstration of rounding necessary to represent most fractional numbers on a computer.
convert.decimal.fraction.to.binary(d, e, ndigits = 54)
d |
the integer part of the decimal fraction. |
e |
the exponent for 10^(-e) |
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.
This function returns the
**NOTE:** Both d and e 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.binary(1, 1)
# Binary expansion of 1/2 = 5/10^1
convert.decimal.fraction.to.binary(5, 1)
# Binary expansion of 1/100 = 1/10^2
convert.decimal.fraction.to.binary(1, 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.