MESSAGE
DATE | 2010-02-22 |
FROM | Ruben Safir
|
SUBJECT | Subject: [NYLXS - HANGOUT] [ruben@mrbrklyn.com: [knking@gsu.edu: Re: C Programming and Modern
|
----- Forwarded message from Ruben Safir -----
X-Original-To: mrbrklyn-at-panix.com Delivered-To: mrbrklyn-at-panix.com Date: Mon, 22 Feb 2010 03:16:43 -0500 From: Ruben Safir To: mrbrklyn-at-panix.com Subject: [knking-at-gsu.edu: Re: C Programming and Modern Approach question] User-Agent: Mutt/1.5.20 (2009-06-14)
----- Forwarded message from "K. N. King" -----
Date: Sat, 20 Feb 2010 00:38:29 -0500 From: "K. N. King" To: Ruben Safir Subject: Re: C Programming and Modern Approach question User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
I think the problem is that you're using %li to display the value of an unsigned long. If you use %lu, you'll see the true value of y. Also note that it's not a good idea to mix a negative signed integer with an unsigned integer, since the result will rarely be what you want.
--Kim King
Ruben Safir wrote: > Hello Dr King, > > I'm reviewing your text while assigning it for a class in NYC > and my students and I are looking at an inconsistancy in the section on > inmplicit type conversion. Your text in the first edition, on page 127 > says that integer promotion promotes from > > int -> unsigned int -> long -> unsigned long > > Test this with GCC: > > #include > > long int x = -500; > unsigned long int y = 100; > > int main(){ > y = x + y; > printf("==> %li \n", y); > return 0; > } > > The sign remains. If anything, the unsigned long sems to promote to > signed. If this an error in the text, a change in the C standard, or > percular to GCC > > Ruben Safir
----- End forwarded message -----
-- http://www.mrbrklyn.com - Interesting Stuff http://www.nylxs.com - Leadership Development in Free Software
So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998
http://fairuse.nylxs.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
"Yeah - I write Free Software...so SUE ME"
"The tremendous problem we face is that we are becoming sharecroppers to our own cultural heritage -- we need the ability to participate in our own society."
"> I'm an engineer. I choose the best tool for the job, politics be damned.< You must be a stupid engineer then, because politcs and technology have been attached at the hip since the 1st dynasty in Ancient Egypt. I guess you missed that one."
? Copyright for the Digital Millennium
----- End forwarded message -----
|
|