MathGroup Archive 2004

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

Search the Archive

Re: SetPrecision - What does in find?

"Kazimir" wrote

>SetPrecision[.14, Infinity]
>    1261007895663739/9007199254740992

>What is the mathematical (in the sens of mathemaics as a science) reason to
>give this answer? I would say that 7/50 is much a better answer.

0.14 is a machine precision number whose 'exact' expression is not
representable with a finite number of binary digits of mantissa.
In most 32 bits machines a machine precision number has 53 bits of mantissa
(this gives roughly 16 decimal digits).
In base 2, 0.14 looks like this:


And the trailing dots mean that the expansion goes on after that point.
If you truncate the binary expansion of the mantissa to the 53rd digit
(actually it could be one digit less, because of the normalization)
you get the machine representable number closest to 0.14.
It has at least 16 digits in common with 0.14.

If you compute with infinite precision the sum of the (negative) powers of 2
corresponding to that expansion, you should get


Try this:

    {mantissa, exp} = RealDigits[0.14, 2]
    fract= PadLeft[mantissa, Length[mantissa] - exp]
    MapIndexed[#1*(1/2^#2) & , fract]
    Plus @@ %

Does it work?

Invalid address in reply-to. Crafty demunging required to mail me.

  • Prev by Date: RE: Removing brakets of a list
  • Next by Date: Eigensystem: different solution in V5.0 and V4.1 ??
  • Previous by thread: Re: SetPrecision - What does in find?
  • Next by thread: RE: SetPrecision - What does in find?