MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: a bug in RealDigits? Mathematica 5.0

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45214] Re: [mg45211] a bug in RealDigits? Mathematica 5.0
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Sun, 21 Dec 2003 03:42:09 -0500 (EST)
  • References: <200312201056.FAA09603@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On 20 Dec 2003, at 19:56, steve_H wrote:

> hello;
>
> Mathematica 5.0, student version, on XP home edition:
>
> t1 = 39383738378094852309445543850343.49494
>
> {c, d} = RealDigits[t1];
>
> now c is
>
> {3, 9, 3, 8, 3, 7, 3, 8, 3, 7, 8, 0, 9, 4, 8, 5, 2, 3, 0, 9,
> 4, 4, 5, 5, 4, 3, 8, 5, 0, 3, 4, 3, 4, 9, 4, 9}
>
> notice that I typed in the last digits of t1 as '.49494', i.e the
> number to the right of the decimal point.
>
> But 'c' above is missing the last digit, it only reports '4,9,4,9'
> instead of '4,9,4,9,4'
>
> What happened to the last digit '4' ?
>
>
>

If you read the documentation (generally a good idea) you wil find:

"RealDigits[x] normally returns a list of digits whose length is equal 
to Precision[x]".

So now what it the precision of your number?


t1 = 39383738378094852309445543850343.49494;

Precision[t1]

36.59531693780311

So this tells you that RealDigits will return you only 36 digits:


Length[RealDigits[t1][[1]]]

36

Now, however, let's try:

In[87]:=
t1 = SetPrecision[t1, 37];


RealDigits[t1]


{{3, 9, 3, 8, 3, 7, 3, 8, 3, 7, 8, 0, 9, 4, 8, 5, 2, 3,
    0, 9, 4, 4, 5, 5, 4, 3, 8, 5, 0, 3, 4, 3, 4, 9, 4, 9,
    4}, 32}

You got the last 4. Conclusion: no bug.




Andrzej Kozlowski
Chiba, Japan
http://www.mimuw.edu.pl/~akoz/


  • Prev by Date: Re: a bug in RealDigits? Mathematica 5.0
  • Next by Date: Re: Power Series for LogIntegral
  • Previous by thread: a bug in RealDigits? Mathematica 5.0
  • Next by thread: Re: a bug in RealDigits? Mathematica 5.0