0

I'm filling a dictionary with floating point number, but I have noticed that python tends to "adjust" the values. This is a bit spooky, because the same values will be used later as denominators and even these small changes may generate a division by zero. How can I be sure I'm not getting random rounding up for my numbers.

#python2.7
>>> x = {'set1': 0.59999999999999998, 'set2': 0.66666666666666663}
>>> print x
{'set_1': 0.6, 'set_2': 0.6666666666666666}
>>> print x["set1"]
0.6
>>> print x["set2"]
0.666666666667 
j91
  • 451
  • 1
  • 4
  • 14

0 Answers0