On Aug 7, 4:25 pm, Mihai Rusu <di...@1and1.rowrote:
I am trying to figure out if the standard allows integral type
representations with padding (ie value representation !=
object representation).
A conforming implementation can have:
- a 32bit int and 32bit unsigned int but have the unsigned int
not use the sign bit for value representation? (so INT_MAX ==
UINT_MAX == 2^32-1)
There has been some discussion about this recently, and
apparently, the wording of the C++ standard doesn't allow this.
I'm pretty sure that this was unintentional, however, as the C
standard explicitly allows it, and it is necessary on machines
with no hardware support for unsigned (Unisys MCP, for example).
There is currently an open issue concerning it before the C++
standards committee (active issue 689, open).
- a 33bit int and a 33bit unsigned int and both types have the
33th bit as padding?
By reading 3.9.1 I suppose they can have padding.
Certainly. On a Unisys MCP:
CHAR_BIT == 8
sizeof(int) == 6
INT_MAX == 2^39
UINT_MAX == 2^39
48 bits, 8 padding, 1 sign. (Note that there can even be
trapping representations. On the above, the 8 padding bits are
required to be 0, although I'm not sure what happens if they
aren't.)
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34