Path: utzoo!utgpu!attcan!uunet!mcvax!hp4nl!bsiao!tvdl From: tvdl@bsiao.UUCP (Timo van der Laan) Newsgroups: comp.lang.c Subject: Conversion of unsigned long to double Message-ID: <515@bsiao.UUCP> Date: 21 Apr 89 13:43:56 GMT Reply-To: tvdl@bsiao.UUCP (Timo van der Laan) Organization: POSTBANK N.V., Amsterdam Lines: 33 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"