Math errors in python

Grant Edwards grante at visi.com
Tue Sep 21 10:29:11 EDT 2004


On 2004-09-21, Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:

> On 20 Sep 2004 17:51:28 GMT, Grant Edwards <grante at visi.com> declaimed
> the following in comp.lang.python:
>
>> 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.
>
> I'll concede that I may have missed something in the thread...
> But if one were to propose using a floating BCD for something
> with only 7 significant decimal digits just to get decimal
> "repeating digits" rather than binary ones... (1/3=
> 0.33333333....) I'd be looking for a different proposal.

What proposal?  I was just pointing out that the poster who
claimed that BCD didn't have the range that binary did was
wrong.  He wasn't comparing BCD vs. binary, he was comparing
fixed point vs. floating point.  Fixed point BCD and fixed
point binary both have the same issues with range.

> Add in that an exponent shift is a change of 10, vs a change
> of 2 (assuming common normallized binary -- my college machine
> used exponents that were powers of 16, meaning a normalized
> binary could have up to three 0-bits) -- somehow it just feels
> like the powers of two would retain finer precision when doing
> addition.

For the same storage space, binary FP will have more precision
and/or range.  BCD doesn't use 40% of the code space.

-- 
Grant Edwards                   grante             Yow!  Join the PLUMBER'S
                                  at               UNION!!
                               visi.com            



More information about the Python-list mailing list