delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/14/07:04:11

Date: Wed, 14 Jan 1998 14:03:10 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Nate Eldredge <eldredge AT ap DOT net>, Noam Rotem <nrotem AT johnbryce DOT co DOT il>,
djgpp AT delorie DOT com
Subject: Re: Bit fields in djgpp
In-Reply-To: <Pine.SUN.3.91.980114131317.8730G-100000@is>
Message-ID: <Pine.SUN.3.91.980114140050.8730c-100000@is>
MIME-Version: 1.0

On Wed, 14 Jan 1998, I wrote:

> On Tue, 13 Jan 1998, Nate Eldredge wrote:
> 
> > Solution: Declare the bitfields as `unsigned'.
> 
> I'm not sure this solution is indeed required.  I think what Noam
> reported was due to the effect of `printf', and the actual value
> stored inside the variable was correct.

Sorry, I was wrong.  The ANSI C Standard explicitly says that signed bit 
fields of size N can be used to represent values in the range [0, 2^(N-1))
so when N is 1, you cannot represent 1.  You need to make it unsigned, as 
Nate suggested.

- Raw text -


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