Conversion of unsigned long to double
Timo van der Laan
tvdl at bsiao.UUCP
Fri Apr 21 23:43:56 AEST 1989
The C-compiler for IX370 (running on a 9370 machine) treats an
unsigned long as a signed long if that unsigned long is assigned to
a double. (See the program below).
Is this behavior permitted in ANSI?
**** program ****
main(){
unsigned long l;
double d;
l=2100000000L;
d=l;
printf("%11u %13.0f\n",l,d);
l=2200000000L;
d=l;
printf("%11u %13.0f\n",l,d);
}
**** Output on IBM 9370 (IX370)**** | **** Output on a Vax (4.3 bsd) ****
2100000000 2100000000 | 2100000000 2100000000
2200000000 -2094967296 | 2200000000 2200000000
I found this just before a large program went into production.
If it's a bug, I'll bet that IBM will change the manual instead of
repairing the compiler. (Just as they did after I told them that
rm -rf ../dir did not remove the directory because of the ../ )
--
Timo van der Laan, Postbank N.V., room 4.94 ...mcvax!hp4nl!bsiao!tvdl
Pb 21009
1000 EX AMSTERDAM Phone: + 31 20 5843175
"Real programmers don't wear ties"
More information about the Comp.lang.c
mailing list