Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > integral (non char) types allow padding?

Reply
Thread Tools

integral (non char) types allow padding?

 
 
Mihai Rusu
Guest
Posts: n/a
 
      08-07-2008
Hello

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)
- 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.

--
Dizzy

 
Reply With Quote
 
 
 
 
James Kanze
Guest
Posts: n/a
 
      08-08-2008
On Aug 7, 4:25 pm, Mihai Rusu <(E-Mail Removed)> wrote:

> 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:(E-Mail Removed)
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C++ 42 11-04-2008 12:39 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C Programming 45 11-04-2008 12:39 PM
integral types SasQ C++ 13 03-30-2007 10:10 AM
size and nomenclature of integral types Shailesh C++ 4 04-04-2004 06:37 AM
sizeof C integral types ark C Programming 45 01-19-2004 05:16 PM



Advertisments