Re: [Hampshire] Python multiplicaton

Top Page

Reply to this message
Author: Stephen Pelc
Date:  
To: hampshire
Subject: Re: [Hampshire] Python multiplicaton
> Hugo Mills wrote:
> >    Another alternative would be to use the decimal module[1] for all
> > your numbers.

> >
> >    Hugo.

> >
> > [1] http://docs.python.org/library/decimal.html
> >
> That works perfectly for me - thanks


As a side note to this, I'm involved in a construction planning
application - it planned the new Hong Kong airport.

The competing apps use standard IEEE floating point. Our app
uses 128 bit integers and an implied binary point. This is
sometimes called fixed point arithmetic.

When you put a pile into the ground, the top of the pile is
rough and not suitable for immediate construction. Consequently,
the piles are capped to form a smoother surface. In estimating
the cost of the concrete for the capping, the difference between
the integer calculation and the floating-point calculation was
US$10,000,000. The integer calculation was right.

Floating point is always an approximation. Under some conditions
it can lead you into an awful mess. There's a paper by Goldberg
that is a good reference
http://docs.sun.com/source/806-3568/ncg_goldberg.html

Stephen
--
Stephen Pelc, stephen@???
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691
web: http://www.mpeforth.com - free VFX Forth downloads


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.