13
$\begingroup$

I don't understand how to manipulate numbers with repeating decimal in Wolfram Mathematica language.

For example 0.3... does not work as input and I don't see how to add a vinculum to indicate the repeating part either. There's no manual or something on the issue on the net. Something strange and unusable 0.12(34)^_ (repeating decimal) is given by Wolfram Alpha.

$\endgroup$
1
  • 7
    $\begingroup$ It's probably easiest to just add it as a fractional term if you need arbitrary precision 12/100+(34/99)/100. $\endgroup$ – eyorble Feb 25 at 1:16
19
$\begingroup$

Indeed, there is no direct method to input a repeating decimal. The closest you can get is to input the repeating digits into FromDigits[]:

$$0.\overline{142857}$$

FromDigits[{{{1, 4, 2, 8, 5, 7}}, 0}]
   1/7

$$0.\overline{3}$$

FromDigits[{{{3}}, 0}]
   1/3

$$0.1\overline{6}$$

FromDigits[{{1, {6}}, 0}]
   1/6

Of course, this also applies for e.g. repeating binary representations:

$${0.000\overline{1100}}_2$$

FromDigits[{{0, 0, 0, {1, 1, 0, 0}}, 0}, 2]
   1/10
$\endgroup$
1
  • 1
    $\begingroup$ Thank you very much. $\endgroup$ – Simpleton Jack Feb 25 at 2:04
11
$\begingroup$

Use the Resource Function

ResourceFunction["RepeatingDecimalToRational"][0.3, 1]

(* 1/3 *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.