Email List: Xaustin-review-lX
[All Lists]

Re: Defect in XSH exp

To: yyyyyyyy@xxxxxxx
Subject: Re: Defect in XSH exp
From: "Clive D.W. Feather" <yyyyy@xxxxxxxxx>
Date: Wed, 16 Jul 2003 17:46:31 +0100
Cc: yyyyyyyyyyyyyyy@xxxxxxxxxxxxx
References: <200307161518.QAA08192@xxxxxx>
yyyyyyyy@xxxxxxx said:
> {
>   static double c = 0.39894228040143267794;  /* 1.0/sqrt(2*M_PI) */

Not a good idea, since this may or may not be the right sequence of digits
for any given implementation.

>   return c*exp(-x*x/2);
> }

If you can't just put:

    return exp(-x*x/2) / sqrt (2*M_PI);

then do something like:

    static double c = 0;

    if (c < 0.25)
        c = 1.0 / sqrt (2 * M_PI);

-- 
Clive D.W. Feather  | Work:  <yyyyy@xxxxxxxxx>   | Tel:    +44 20 8495 6138
Internet Expert     | Home:  <yyyyy@xxxxxxxxxx>  | *** NOTE CHANGE ***
Demon Internet      | WWW: http://www.davros.org | Fax:    +44 870 051 9937
Thus plc            |                            | Mobile: +44 7973 377646

<Prev in Thread] Current Thread [Next in Thread>