In the Details of the document of RealDigits writes the following line:

RealDigits[x] normally returns a list of digits of length Round[Precision[x]].

Then when will RealDigits[x] abnormally return something and what will be returned?

The details has shown us one of them:

RealDigits[0.] gives {{0},-Floor[Accuracy[0.]]}.

Are there more?

The following is one I found today:

x = 1.2``2;
(* 2 *)
(* 3 *)

Is there a complete summary for the behaviors of RealDigits with only one valid argument? Does these abnormalities follow any unified rule?


1 Answer 1

test[x_] := 
 With[{a = Length[First@RealDigits[x]], b = Round[Precision[x]]},
  a == b

the test is False for any Integer and Rational, exact symbols like Pi, etc.

Its also False for N[m, n] for any m power of 10 and n been an Integer. As well as for some other Real numbers, I'm guessing depending on the internal representation.

test[N[1, 10.3]]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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