delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/11/17/08:25:17

X-Authentication-Warning: acp3bf.physik.rwth-aachen.de: broeker owned process doing -bs
Date: Tue, 17 Nov 1998 14:22:16 +0100 (MET)
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
X-Sender: broeker AT acp3bf
To: DJGPP Workers List <djgpp-workers AT delorie DOT com>
Subject: Re: gcc: feature or bug?
In-Reply-To: <19981117131553.B17146@duna58>
Message-ID: <Pine.LNX.3.93.981117142107.7061M-100000@acp3bf>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com

On Tue, 17 Nov 1998, Laszlo Molnar wrote:

> Hi Workers!
> 
> Just a small question:
> 
> Let's say I have a 32-bit unsigned integer, and I want to clear it's
> most significant bit. I wrote this code:
> 
> 	(x*2)/2
> 
> And of course(?) it doesn't work. Is it a bug in gcc or a bug in me?

A bug in you :-) To get what you want, you should have written either

	(x / 2) * 2

or 	(x >> 1) << 1

or      x & (~ 0x1U)

Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


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