From: Ron Natalie <ron@sensor.com>
Subject: Re: Bug in C compiler?
Date: 1996/09/19 [thread overview]
Message-ID: <32419569.1BB3@sensor.com> (raw)
In-Reply-To: 4buf2zhlw.fsf@ruls41.fsw.LeidenUniv.nl
Theo Vosse wrote:
>
> Hi,
>
> I wrote this piece of program:
>
> static double FillBinomTable(double tab[], int b)
> {
> double factor = 1.0 / pow(2.0, b);
>
> which fills a table with binomial probabilities. The problem is that
> when I use DEC's c compiler (with -g), 'factor' becomes 0.707106...,
> which is sqrt(2), whereas when I use gcc, it becomes 1/(2**b). The
> last one is correct.
>
Actually, .707... is 1/sqrt(2) or most likely 1/ pow(2.0, 0);
Any chance that you don't have "pow" properly declared. It looks
like "b" might be passed to power as an "int" (it wants double).
You are using the ANSI compiler flags?
A real quick test would be to cast b to double....
-Ron
next prev parent reply other threads:[~1996-09-19 4:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-09-19 4:00 Bug in C compiler? Theo Vosse
1996-09-19 4:00 ` Stephen Hoff Hoffman
1996-09-19 4:00 ` Ron Natalie [this message]
1996-09-19 4:00 ` Ron Natalie
1996-09-20 4:00 ` Phil Ottewell
1996-09-20 4:00 ` Theo Vosse
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox