This is the mail archive of the
`gcc@gcc.gnu.org`
mailing list for the GCC project.

# Re: numerical instability and estimate-probability

*From*: Geert bosch <bosch at gnat dot com>
*To*: mike stump <mrs at windriver dot com>
*Cc*: gcc-pdo at atrey dot karlin dot mff dot cuni dot cz, gcc at gcc dot gnu dot org, jh at suse dot cz,rth at cygnus dot com
*Date*: Thu, 15 Nov 2001 17:19:53 -0500
*Subject*: Re: numerical instability and estimate-probability

On Thursday, November 15, 2001, at 02:31 , mike stump wrote:
> One can `fix' this by doing the arithmetic in double, doing it safely,
> and then chopping the number down to say, 5 or 10 digits at the end.
> This way increase the odds that the numbers will be the same of all
> platforms, and that the same code will be generated. [ crossed
> fingers we can do without a portible math library ]
In practice you will not achieve this. With probabilities, one
might often end up in exact inbetween cases, where double rounding
as is done on x86 when using double can wreak havoc. Even apart
from the x86, it is hard to guarantee bit-identical results on
different systems.
I think GCC should just not use floating-point arithmetic at all
for making code generation decisions. It might be best to define
a probability type using integers and have some functions for adding
and multiplying them.
-Geert