ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2011/09/10/10:47:55

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
From: Sterten AT aol DOT com
Message-ID: <8c30b.37d5743f.3b9cd022@aol.com>
Date: Sat, 10 Sep 2011 10:37:22 -0400 (EDT)
Subject: Re: A printf problem?
To: djgpp AT delorie DOT com
MIME-Version: 1.0
X-Mailer: 9.0 SE for Windows sub 5022
X-Originating-IP: [78.49.70.26]
x-aol-global-disposition: G
X-AOL-SCOLL-SCORE: 0:2:341491328:93952408
X-AOL-SCOLL-URL_COUNT: 0
x-aol-sid: 3039ac1d290a4e6b7622177d
Reply-To: djgpp AT delorie DOT com

--part1_8c30b.37d5743f.3b9cd022_boundary
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

=20
you may have a typo
52258 for the first, not 55258
=20
=20
=20
In einer eMail vom 10.09.2011 15:45:30 Westeurop=E4ische Normalzeit schreib=
t =20
mok-kong DOT shen AT t-online DOT de:

Hi,

Maybe I have made a very grave mistake, but I just can't yet  understand
why the code attached below produced the following  output:

first:      cc22        55258
second:     d7da        55258
third:      ffff        65535

Why are the first two numbers, which are different  hexadecimals,
printed out as the same decimal number?

Thanks for  your kind help in advance.

M. K.  Shen

------------------------------------------------------
#include  <stdio.h>

int main()
{ unsigned long int  g;

g=3D0xcc22; printf("first:  %8x   %10lu\n",g,g);

g=3D0xd7da; printf("second: %8x   %10lu\n",g,g);

g=3D0xffff; printf("third:  %8x   %10lu\n",g,g);

return(0);
}




--part1_8c30b.37d5743f.3b9cd022_boundary
Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3DISO-8859-1"=
>
<META content=3D"MSHTML 6.00.5730.11" name=3DGENERATOR></HEAD>
<BODY id=3Drole_body style=3D"FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY:=
 Arial"=20
bottomMargin=3D7 leftMargin=3D7 topMargin=3D7 rightMargin=3D7><FONT id=3Dro=
le_document=20
face=3DArial color=3D#000000 size=3D2>
<DIV>
<DIV>you may have a typo</DIV>
<DIV>52258 for the first, not 55258</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>In einer eMail vom 10.09.2011 15:45:30 Westeurop=E4ische Normalzeit sc=
hreibt=20
mok-kong DOT shen AT t-online DOT de:</DIV>
<BLOCKQUOTE=20
style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: blue 2px solid">=
<FONT=20
  style=3D"BACKGROUND-COLOR: transparent" face=3DArial color=3D#000000=20
  size=3D2>Hi,<BR><BR>Maybe I have made a very grave mistake, but I just ca=
n't yet=20
  understand<BR>why the code attached below produced the following=20
  output:<BR><BR>first:&nbsp; &nbsp; &nbsp; cc22&nbsp; &nbsp; &nbsp;&nbsp;=
=20
  55258<BR>second:&nbsp; &nbsp;&nbsp; d7da&nbsp; &nbsp; &nbsp;&nbsp;=20
  55258<BR>third:&nbsp; &nbsp; &nbsp; ffff&nbsp; &nbsp; &nbsp;&nbsp;=20
  65535<BR><BR>Why are the first two numbers, which are different=20
  hexadecimals,<BR>printed out as the same decimal number?<BR><BR>Thanks fo=
r=20
  your kind help in advance.<BR><BR>M. K.=20
  Shen<BR><BR>------------------------------------------------------<BR>#in=
clude=20
  &lt;stdio.h&gt;<BR><BR>int main()<BR>{ unsigned long int=20
  g;<BR><BR>&nbsp;&nbsp; g=3D0xcc22; printf("first:&nbsp; %8x&nbsp;=20
  %10lu\n",g,g);<BR><BR>&nbsp;&nbsp; g=3D0xd7da; printf("second: %8x&nbsp;=
=20
  %10lu\n",g,g);<BR><BR>&nbsp;&nbsp; g=3D0xffff; printf("third:&nbsp; %8x&n=
bsp;=20
  %10lu\n",g,g);<BR><BR>&nbsp;&nbsp; return(0);<BR>}<BR></FONT></BLOCKQUOTE=
></DIV>
<DIV></DIV>
<DIV>&nbsp;</DIV></FONT></BODY></HTML>
--part1_8c30b.37d5743f.3b9cd022_boundary--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019