0

t is array of two float64 numbers. On typing t in Ipython 2.7, it is giving following output:

array([ 60.211127, 71.08120185])

print t gives

[ 60.211127, 71.08120185]

print t[0] gives

60.211127

but... t[0] gives

60.211126999999998

as an output.

P.S.

from decimal import *
Decimal(t[0])

gives

Decimal('60.21112699999999762212610221467912197113037109375')

as output.Why is it happening so?

cur10us
  • 141
  • 12
  • `print` uses the `str` format, plain interactive `out` uses the `repr` version. Add on top of that the different display conventions for `array` (`numpy`?) and Python floats. – hpaulj Oct 16 '16 at 16:07

1 Answers1

0

The issue I think you are having is because there is no way to approximate some values in some data formats. (the same way you can't show 1/3 because you would just have .3333333333333... forever) There is more info here

a useful function might be repr() more info here

Whud
  • 714
  • 1
  • 6
  • 19