Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unexpected behaviour of arbitrary precision real numbers

I've been trying to use arbitrary precision real numbers and I'm a bit confused. The simple snippet below illustrates my point:

R = RealField(200)
z = R(2.0)
print '%.20f' % (z.sqrt())

I should get (or that's what I was expecting) 1.41421356237309504880, but instead I got 1.41421356237309514547 (a disagreement in the last five decimal places). Where am I goofing up? You see, it's a quite simple code. How could I fix it in order to obtain the desired/expected result.

Thanks in advance for any light shed on this matter.

Fausto

Unexpected behaviour of arbitrary precision real numbers

I've been trying to use arbitrary precision real numbers and I'm a bit confused. The simple snippet below illustrates my point:

R = RealField(200)
z = R(2.0)
print '%.20f' % (z.sqrt())

I should get (or that's what I was expecting) 1.41421356237309504880, but instead I got 1.41421356237309514547 (a disagreement in the last five decimal places). Where am I goofing up? You see, it's a quite simple code. How could I fix it in order to obtain the desired/expected result.result?

Thanks in advance for any light shed on this matter.

Fausto