Message-ID: <324F415E.5123@viemeister.com> Date: Mon, 30 Sep 1996 00:41:18 -0400 From: Ian Viemeister MIME-Version: 1.0 To: Guillermo Ballester Valor CC: djgpp AT delorie DOT com Subject: ldexp problems (was Re: HELP: What's wrong ?) References: <01bbae54$12da4180$LocalHost AT 10 DOT 0 DOT 1 DOT 1 DOT inf> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit This is odd. I checked, and found exactly the same problem (fifth call to ldexp always causes SIGFPE). HOWEVER, if you leave off the "-lm", and use the non-math library ldexp, no floating-point error occurs. As the obivous quick-fix, Guillermo, just don't link with libm.a ***Note to whoever is currently maintaining the math libs: Is this a general bug, or is it possibly related to a particular setup? Ian ian AT viemeister DOT com http://viemeister.com/ Guillermo Ballester Valor wrote: > There is only a problem. I cannot find the solution. When I use 'ldexp' > function, defined in math.h, program breaks. On the contrary Borland > compiler works well. I don't know what's wrong. Below, I have inserted a > simple p.cpp which produces a runtime error. I have observed that it always > appears in fifth call to ldexp, whatever be the arguments. > Compiler Invoke: gxx -g -o p.exe p.cpp -lm > > PROGRAM : P.CPP > > /* This is a simple program test for ldexp function */ > #include > #include > void test(double d, int n) > { > double d1=ldexp(d,n); > printf("\nldexp(%lf , %i ) is %lf",d,n,d1); > } > > main() > { > test(1,1); > test(1,32); > test(4,16); > test(16,32); > test(32,32); > test(2.5,7);// and so on ... Always breaks in fifth call > } > > I would like to know if I am doing something incorrect. Please help me.