Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ukma!uunet!nuchat!uhnix1!sugar!peter From: peter@sugar.UUCP Newsgroups: comp.lang.c Subject: Re: Long integers Message-ID: <769@sugar.UUCP> Date: Wed, 16-Sep-87 16:31:07 EDT Article-I.D.: sugar.769 Posted: Wed Sep 16 16:31:07 1987 Date-Received: Sat, 19-Sep-87 09:19:03 EDT References: <9266@brl-adm.ARPA> Organization: Sugar Land UNIX - Houston, TX Lines: 35 Summary: Bzzzzzt! Are we not men, we are vaxen. In article <9266@brl-adm.ARPA>, moss@BRL.ARPA (Gary S. Moss (SLCBR-VL-V)) writes: > George, > The format %ld is wrong when using the PRINTF family of functions. Nope, it's right. > 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. Integer arguments are widened to INT when passed in to a function. If you always run on Vaxen and 68000s and the like (as you presumably have) you will never have any problems. If you run on PDP11s and 8086s you'll get the most amazing results. > This > is also true for %f. This is true for %f, but not for %d. Probably there didn't happen to be any performance advantage to using the longer floats on a PDP11 and this became entrenched in the language. > I am not certain, but pretty sure that I have gotten > wrong behavior when using %ld in this context on certain hardware. when either your compiler is wrong or you were really using an integer or (more likely) a pointer and assuming it was a long. Pointers may be longs on an 8086, but never are on a PDP11. The Vandata version of the Whitesmiths 'C' compiler on the 8080 actually promoted to char (i.e., didn't promote) when passing integers when you were compiling in the tightest possible mode. This was great for small embedded systems. -- -- Peter da Silva `-_-' ...!hoptoad!academ!uhnix1!sugar!peter -- 'U` ^^^^^^^^^^^^^^ Not seismo!soma (blush)