Can anyone offer a suggestion?

Terry Reedy tjreedy at
Thu Jul 12 13:38:00 EDT 2001

"Emile van Sebille" <emile at> wrote in message
news:9ikgpq$j1cff$1 at
{posted and emailed}

> I've been writing a business math class that allows for multiple
> accuracy, and in testing stumbled on this behavior:
> >>> print '%8.2f' % float(ab*cb)
>   152.34

So BNum.__float__ exists and appears to work correctly (as does __str__ or

> >>> print '%8.2f' % ab*cb
> 151.84

I would try various things before looking at the C source:

insert print in __float__ to see if it is called, and if so, with what.
wrap ab*cb in () and (,)
change 8.2f to s
find other values of ab or cb that give an erroneous result

Terry J. Reedy

More information about the Python-list mailing list