Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ukma!uunet!nuchat!steve From: steve@nuchat.UUCP Newsgroups: comp.lang.c Subject: Re: Long integers Message-ID: <318@nuchat.UUCP> Date: Wed, 16-Sep-87 13:06:38 EDT Article-I.D.: nuchat.318 Posted: Wed Sep 16 13:06:38 1987 Date-Received: Sat, 19-Sep-87 07:46:19 EDT References: <9266@brl-adm.ARPA> Organization: Public Access - Houston, Tx Lines: 31 Summary: This flamage is just plain wrong. In article <9266@brl-adm.ARPA>, moss@BRL.ARPA (Gary S. Moss) 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. This can't be allowed to stand. In C, scalar types smaller than an int are promoted to _int_ when passed to a function, including printf. Thus there is no need for special provisions for printing shorts or chars as integers. But long may be larger than int, which you would know if you didn't program vax's or vax-alikes, and thus a special indicator is required for printing longs. > This is contrary to the SCANF family where you *need* the %ld because > you are placing the result in an address whose type is not known to the > function. True. One would also need special indicators for short and char if one wanted to be able to scanf '%d' into them. A similar thing happens with floting point: floats and doubles are passed to printf as double, so only one %f is needed. But scanf would have to know which was being pointed to to poke the converted value properly. -- Steve Nuchia Of course I'm respectable! I'm old! {soma,academ}!uhnix1 Politicians, ugly buildings, and whores !nuchat!steve all get respectable if they last long enough. (713) 334 6720 - John Huston, Chinatown