Can anyone offer a suggestion?

Bernhard Herzog bh at intevation.de
Thu Jul 12 13:41:28 EDT 2001


"Emile van Sebille" <emile at fenx.com> writes:

> I've been writing a business math class that allows for multiple precision
> accuracy, and in testing stumbled on this behavior:
> 
> >>> from BNum import BNum as bn
> 
> >>> ab = bn('1.2340000')
> >>> cb = bn('123.45')
> >>> ab
> 1.2340000
> >>> ab * cb
> 152.3373000
> >>> (ab*cb).disp(2)
> '152.34'
> >>> print '%8.2f' % ab*cb
> 151.84
> +++++++++++++++++++++??????!

This is equivalent to

print ('%8.2f' % ab) * cb

:-)

And since 

>>> 1.23 * 123.45
151.84350000000001

the output 151.84 seems reasonable to me.

  Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Sketch                                 http://sketch.sourceforge.net/
MapIt!                                               http://mapit.de/



More information about the Python-list mailing list