Hi, I am writing code that will deal with currencies, charges, etc.. I am going to use the BigDecimal class for math & storage.
We ran into something weird with it, however.
Using this statement:
1876.8 == BigDecimal('1876.8')
it returns false.
If I run those values through a formatting string "%.13f" I get:
"%.20f" % 1876.8 => 1876.8000000000000
"%.20f" % BigDecimal('1876.8') => 1876.8000000000002
Note the extra 2 from the BigDecimal at the 13th decimal place.
I thought BigDecimal was supposed to counter the inaccuracies of storing real numbers directly in the native floating point of the computer. Where is this 2 coming from?