Date: Fri, 29 Jan 1999 12:49:41 -0500 Message-Id: <199901291749.MAA15266@envy.delorie.com> From: DJ Delorie To: djgpp AT delorie DOT com In-reply-to: <36B1EDB5.53C1FDCB@net4you.co.at> (message from Seawolf on Fri, 29 Jan 1999 18:19:49 +0100) Subject: Re: Bitshifting References: <36B1EDB5 DOT 53C1FDCB AT net4you DOT co DOT at> Reply-To: djgpp AT delorie DOT com > int value = 0x000F; > unsigned long c; > > c = value + (value<<8) + (value<<16) + (value<<24); Try this: c = value + (value<<8) + ((unsigned long)value<<16) + ((unsigned long)value<<24L); The expressions aren't promoted until after the shifts (at the time of the assignment), but by then it's too late. You need to promote them before the shifts.