Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!burl!codas!killer!richardh From: richardh@killer.UUCP Newsgroups: comp.sys.ibm.pc Subject: Re: tc bug? Message-ID: <1654@killer.UUCP> Date: Sat, 26-Sep-87 19:10:03 EDT Article-I.D.: killer.1654 Posted: Sat Sep 26 19:10:03 1987 Date-Received: Sun, 27-Sep-87 22:19:46 EDT References: <236@occrsh.ATT.COM> Organization: The Unix(R) Connection, Dallas, Texas Lines: 21 Summary: no bug; %d is int not unsigned In article <236@occrsh.ATT.COM>, uucp@occrsh.UUCP writes: > unsigned int xyz = 0x8000 ; > > main() > { > printf("xyz=%d\n", xyz) ; > } > > ...gives me -32768. Really screws things up trying to read files in 32k > chunks. Printf only knows the types of its parameters by looking at the format string. The conversion char %d specifies a signed int. Use %u (or %o or %x) if you want to see the 16-bit value as an unsigned. The bit pattern 0x8000 IS -32768 when interpreted as a signed two's-complement decimal number. richard hargrove ..!inhp4!killer!richardh ------------------------