Re: Math errors in python

From: Grant Edwards (grante_at_visi.com)
Date: 09/20/04


Date: 20 Sep 2004 17:51:28 GMT

On 2004-09-20, Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote:
> On 20 Sep 2004 14:34:03 GMT, Grant Edwards <grante@visi.com> declaimed
> the following in comp.lang.python:
>
>> On 2004-09-20, david h <daveh@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!


Relevant Pages

  • Re: This calculation is just wrong / computer cant count!
    ... Most BCD has precision limits, ... That way, cumulative roundoff won't distort images nearly as much, because I ... binary floating point CPU clock cycle ...
    (microsoft.public.vc.mfc)
  • Re: Calculate the precision of a floating point number (ie: the number of decimal places)
    ... I did not think you wanted the precision (since with internal floating ... binary floating point). ... string as if you were going to print it out. ...
    (comp.programming)
  • Re: gcc strangeness
    ... binary floating point arithmetic, rather than gcc. ... The correct solution is to use rint(3), ... Switching to double precision will help but is still not a complete ...
    (freebsd-hackers)
  • Re: A Simplified Number System
    ... > Fixed point is as opposed to floating point. ... Normal integers and normal arithmetics. ... No weird BCD, no special structures. ... digits for the integral part, ...
    (sci.lang)
  • Re: A Simplified Number System
    ... > Fixed point is as opposed to floating point. ... The exponent is implicit. ... integers and normal arithmetics. ... weird BCD, no special structures. ...
    (sci.lang)

Loading