Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!bloom-beacon!gatech!gt-eedsp!sam From: sam@gt-eedsp.UUCP (Sam Smith) Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: Turboc bug (float to long) Message-ID: <140@gt-eedsp.UUCP> Date: Tue, 8-Dec-87 14:05:48 EST Article-I.D.: gt-eedsp.140 Posted: Tue Dec 8 14:05:48 1987 Date-Received: Sun, 13-Dec-87 13:33:15 EST Distribution: na Organization: School of Electrical Engineering, Ga. Tech, Atlanta, GA 30332 Lines: 40 Keywords: turboc Xref: mnetor comp.sys.ibm.pc:10946 comp.lang.c:5796 I found the following bug in Turboc v1.0. The same program works correctly under MSC 4.0 and Unix C. #include#include main() { long longvalue; float floatvalue; floatvalue = -100.0; printf("%f\n", floatvalue); longvalue = (long)floatvalue; printf("%ld\n", longvalue); } output: -100.0 65436 The second number should be -100 not 65436. This program works for positive floats and doubles. From what I can figure out the call to _ftol should return the long value in DX:AX. AX is correct, DX should be 0xffff but is actually 0x0000. DX is not getting sign extended. Sam Smith Digital Signal Processing Lab, Georgia Tech, Atlanta GA 30332 Internet: sam%gteedsp@gatech.gatech.edu uucp: ...!{decvax,hplabs,ihnp4,linus,rutgers,seismo}!gatech!gt-eedsp!sam -- Sam Smith Digital Signal Processing Lab, Georgia Tech, Atlanta GA 30332 Internet: sam%gteedsp@gatech.gatech.edu uucp: ...!{decvax,hplabs,ihnp4,linus,rutgers,seismo}!gatech!gt-eedsp!sam