From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,4f7a405235f760ec X-Google-Attributes: gid1164f8,public From: Ron Natalie Subject: Re: Bug in C compiler? Date: 1996/09/19 Message-ID: <32419569.1BB3@sensor.com>#1/1 X-Deja-AN: 184000546 references: <4buf2zhlw.fsf@ruls41.fsw.LeidenUniv.nl> content-type: text/plain; charset=us-ascii organization: Sensor Systems mime-version: 1.0 newsgroups: comp.sys.dec x-mailer: Mozilla 2.01 (X11; I; HP-UX A.09.05 9000/755) 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