the following test program causes me trouble under GCC-3.2.1 (Linux
2.4.19-gentoo-r9 #1 SMP i686 Intel(R) Pentium(R) 4 CPU 2.40GHz
GenuineIntel GNU/Linux gcc-3.2.1 glibc-2.3.1)
#include <stdio.h>
#include <math.h>
int main()
{
double x = 1.1;
double y;
printf("Calling modf() for %f\n", x);
printf("fractional part = %f\ninteger part = %f\n",
modf(x, &y), y);
return 0;
}
The expected output would be:
Calling modf() for 1.100000
fractional part = 0.100000
integer part = 1.000000
However I get:
$ gcc test.c -o test
$ ./test
Calling modf() for 1.100000
fractional part = 1.100000
integer part = -0.000000
which is obviously false (I get a similar wrong result with MinGW under Win2k).
Can anyone please help me with that issue? How can I locate the error? Is
is a bug with gcc-3.2.1? Thanks!
Kind regards,
lemonite
Seems so, or maybe in the libc. It's working here with gcc 3.2. The
output is:
The evaluation order of the function parameters is undefined.
It's better to do something like:
z = modf(x,&y);
printf("fractional part = %f\ninteger part = %f\n", z, y);
Wei
>> Seems so, or maybe in the libc. It's working here with gcc 3.2. The
>> output is:
>>
>> Calling modf() for 1.100000
>> fractional part = 0.100000
>> integer part = 1.000000
>>
>>
>
> The evaluation order of the function parameters is undefined.
> It's better to do something like:
>
> z = modf(x,&y);
> printf("fractional part = %f\ninteger part = %f\n", z, y);
Of course. I just overlooked that.
I forgot ;). However it does not 'solve' the problem.
Kind regards,
lemonite