Article View: comp.lang.c.moderated
Article #2295Re: 'h' modifier in printf
From: Dan Pop
Date: Fri, 15 Mar 1996 03:14
Date: Fri, 15 Mar 1996 03:14
24 lines
1218 bytes
1218 bytes
In <4i99vc$91r@solutions.solon.com> dickey@clark.net (T.E.Dickey) writes:
>Michael J Zehr (tada@athena.mit.edu) wrote:
>: The "h" modifier says the corresponding argument will be printed as a
>: short or unsigned short.
>...
>: short s;
>: printf("%d", s);
>: printf("%hd", s);
>...
>: Can these two ever be different? I'm aware of course that the short is
>: widened to an int during the function call, but this preserves the
>: value.
>sure can -- you're overlooking sign extension
How much time did you spent thinking, before posting this pearl of wisdom?
Dan
--
Dan Pop
CERN, CN Division
Email: danpop@mail.cern.ch
Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
Technical Details
Message-ID:
<4ianaf$h6u@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailReferences:
<4i801c$455@solutions.solon.com> <4i99vc$91r@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: danpop@mail.cern.ch (Dan Pop) Newsgroups: comp.lang.c.moderated Subject: Re: 'h' modifier in printf Date: 14 Mar 1996 21:14:23 -0600 Organization: CERN European Lab for Particle Physics Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4ianaf$h6u@solutions.solon.com> References: <4i801c$455@solutions.solon.com> <4i99vc$91r@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com X-Newsreader: NN version 6.5.0 #7 (NOV)