Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!mtune!westmark!dave From: dave@westmark.UUCP Newsgroups: comp.lang.c Subject: Re: Long integers Message-ID: <164@westmark.UUCP> Date: Thu, 17-Sep-87 00:07:40 EDT Article-I.D.: westmark.164 Posted: Thu Sep 17 00:07:40 1987 Date-Received: Sat, 19-Sep-87 08:43:11 EDT References: <9266@brl-adm.ARPA> Organization: Westmark, Inc., Warren, NJ, USA Lines: 19 In article <9266@brl-adm.ARPA>, moss@BRL.ARPA writes: > George, > The format %ld is wrong when using the PRINTF family of functions. > The reason for this is that integer arguments are *always* widened to LONG > when passed in to a function, so the %d format is meant for LONGS. This > is also true for %f. I am not certain, but pretty sure that I have gotten > wrong behavior when using %ld in this context on certain hardware. If this were true, why was %ld provided? I thought that chars and shorts got promoted to ints. Ints and longs happen to be the same size on some systems, but in general, ints get passed as ints. Printf expects an int when it sees %d and a long when it sees %ld. If they're the same size, you can use them interchangeably, unless you care about portability! -- Dave Levenson Westmark, Inc. A node for news. Warren, NJ USA {rutgers | clyde | mtune | ihnp4}!westmark!dave