Mail Archives: djgpp/1993/10/12/12:33:53
Hi,
I have a floating point problem with the following program.
#include <stdio.h>
#include <math.h>
#define LIMIT (double)1.0e30
main()
{
double dist=LIMIT;
double diffs;
diffs=dist-LIMIT;
printf("%e %e %e\n",dist,diffs,LIMIT);
}
The problem is that instead of printing 1e30 0 1e30, gcc prints 1e30 2e-14 1e30
I created the following .s file
.file "mau.c"
gcc2_compiled.:
___gnu_compiled_c:
.text
LC0:
.ascii "%e %e %e\12\0"
.align 2
LC1:
.double 0d1.00000000000000030000e+30
.align 2
.globl _main
_main:
pushl %ebp
movl %esp,%ebp
subl $16,%esp
call ___main
movl $966823146,-8(%ebp)
movl $1177108057,-4(%ebp)
fldl LC1
fsubrl -8(%ebp)
fstpl -16(%ebp)
pushl $1177108057
pushl $966823146
pushl -12(%ebp)
pushl -16(%ebp)
pushl -4(%ebp)
pushl -8(%ebp)
pushl $LC0
call _printf
addl $28,%esp
L1:
leave
ret
After many tries I found that if I replace the .double statement with
.double 0d1.00000000000000000000e+30
it works right. I think something is wrong with the generation of floating
point constsnts in as. Am I right? In that case are there any fixes?
I already tried gas21fix.zip with no results.
Thanks in advance.
Fabio
P.S. I use djgpp 1.10
- Raw text -