what is the value of .01 python addition -
i'm trying add together 2 floating number , cannot work. need output 100.0 i'm doing wrong here. give thanks advise.
mystring = 'value: 99.9 date: 20130215' tot = float(mystring[8:13]) print (float(tot) + .01)
i need tot = 100.0 if 1 can help give thanks you
i'm getting 99.91
two problems:
adding .01 99.9 results in 99.91, not 100.0. floating point math won't yield think does, because not numbers can represented accurately in floating point. should never expect result of floating pointer operation precise numberfor more on (2), see floating point arithmetic
python
No comments:
Post a Comment