Minimum sizes of integral and floating point types

I

Ioannis Vranos

Is there any mentioning in the standard of the number of bits of the
various built in types, apart from char/signed char/unsigned char types?
Or only about the minimum value ranges of them?
 
V

Victor Bazarov

Ioannis said:
Is there any mentioning in the standard of the number of bits of the
various built in types, apart from char/signed char/unsigned char
types? Or only about the minimum value ranges of them?

It's actually in the C Standard. C++ Standard inherits those.

V
 
J

Jerry Coffin

In C++03, section 5.2.4 is about "Pseudo destructor call". Nothing
relevant ro my question there.

As noted above, the C standard is what's relevant here, so you need to
look at section 5.2.4.2 of the C standard (the C99 standard, to be
specific).
 
J

James Kanze

Is there any mentioning in the standard of the number of bits
of the various built in types, apart from char/signed
char/unsigned char types? Or only about the minimum value
ranges of them?

No. But for integral types, the standard does impose a pure
binary representation, so the minimum value ranges do impose a
minimum number of bits. For floating point types, the standard
imposes minimum ranges and precision, which also imposes a
minimum amount of information present---if a "bit" is a binary
digit, this also imposes a certain minimum number of bits.

There's also a requirement that sizeof be an integral type, and
that you can examine all of the bits of an object (regardless of
its type) using unsigned char. Independently of the requirement
that CHAR_BIT be at least 8, this would forbid the usual PDP-10
organization of 36 bit words, with 5 7 bit bytes per word (and
one unused bit). It doesn't require that all bits participate
in the value representation, however---on a Unisys MCP, for
example, you can see all 48 bits of an int accessing it as an
array of [6] unsigned char, but only 40 participate in the value
representation, and only 39 can be accessed using unsigned int
with shift and masking operations.
 
I

Ioannis Vranos

James said:
No. But for integral types, the standard does impose a pure
binary representation, so the minimum value ranges do impose a
minimum number of bits.


Do you mean that all integer types, signed and unsigned, are required to
not have padding bits?
 
E

Erik Wikström

Do you mean that all integer types, signed and unsigned, are required to
not have padding bits?

Since the standard does impose a pure binary representation and a
minimal interval of values that the integer should be able to store
there is an implicit requirement on the minimum size (in bits) of the
integer types (the minimal number of bits required to store values in
those intervals).
 
J

Jack Klein

Do you mean that all integer types, signed and unsigned, are required to
not have padding bits?

No, that is only true of unsigned char (in C), and all the character
types in C++.

It is also true of the exact-width integer types, if defined, in C99,
not yet but soon to be part of the next C++ standard. They must have
no padding bits and use 2's complement representation for negative
values in the signed types.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
 
J

James Kanze

Do you mean that all integer types, signed and unsigned, are
required to not have padding bits?

No, but the value bits must use a binary representation. (The C
standard says explicitly that the negative representation must
be one of 2's complement, 1's complement or signed magnitude.
C++ tries to say more or less the same thing in more general
terms.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top