Can anyone offer a suggestion?

Emile van Sebille emile at fenx.com
Thu Jul 12 13:50:10 EDT 2001


That's it!  My class is invoking __rmul__, coercing the string to an
instance and doing the math.

Thanks all who responed.

--

Emile van Sebille
emile at fenx.com

---------
"Bernhard Herzog" <bh at intevation.de> wrote in message
news:6qsng2rqnr.fsf at abnoba.intevation.de...
> "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