Math errors in python

Grant Edwards grante at visi.com
Mon Sep 20 19:51:28 CEST 2004


On 2004-09-20, Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:
> On 20 Sep 2004 14:34:03 GMT, Grant Edwards <grante at visi.com> declaimed
> the following in comp.lang.python:
>
>> On 2004-09-20, david h <daveh at dmh2000.com> wrote:
>> 
>> > the problem with BCD or other 'decimal' computations is that it either
>> > doesn't have the dynamic range of binary floating point (~ +-10**310)
>> 
>> Huh?  Why would BCD floating point have any less range than
>> binary floating point?  Due to the space inefficiencies of
>> BCD, it would take a few more bits to cover the same range,
>> but I don't see your point.
>
> 	There /was/ an "or" in that sentence, which you trimmed out...

Sorry about that, but I wasn't addressing the other complaint,
just the lack of range part.

> Though working with numbers that are stored in >150 bytes
> doesn't interest me. Uhm, actually, to handle the +/- exponent
> range, make that 300+ bytes (150+ bytes before the decimal,
> and the same after it).

To get the same range and precision as a 32-bit IEEE, you need
4 bytes for mantissa and 2 for the exponent.  That's 6 bytes,
not 300.

> As soon as you start storing an exponent as a separate
> component you introduce a loss of precision in computations.

I thought you were complaining about range and storage required
for BCD vs. binary.

Floating point BCD can have the same range and precision and
binary floating point with about a 50% penalty in storage
space.

If you're going to compare fixed point verses floating point,
that's a completely separate (and orthogonal) issue.

-- 
Grant Edwards                   grante             Yow!  Let's send the
                                  at               Russians defective
                               visi.com            lifestyle accessories!



More information about the Python-list mailing list