www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/15/03:24:58

From: G DOT DegliEsposti AT ads DOT it
To: djgpp AT delorie DOT com
Message-ID: <C125658D.002D528D.00@vega.ads.it>
Date: Thu, 15 Jan 1998 09:23:50 +0100
Subject: Re: Re: Bit fields in djgpp
Mime-Version: 1.0




>>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
even worse... for N=1 you can use values in range 0 <= x <= -1 i.e. none!
;-)

>>Nate suggested.
>
>Oughtn't that to be:
>[0..(2^(N-1))-1] ?
>Because, for instance, a 16-bit signed value can only go up to 32767.
you both are right! if you look better you will see a ')' where you put a
']'!
Both [a..b-1] and [a..b) specify the same range of integers x such that
a<=x<b.

ciao
  Giacomo



- Raw text -


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