Minimum sizes of integral and floating point types

Discussion in 'C++' started by Ioannis Vranos, Mar 8, 2008.

  1. 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?
     
    Ioannis Vranos, Mar 8, 2008
    #1
    1. Advertising

  2. Ioannis Vranos wrote:
    > 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
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Mar 8, 2008
    #2
    1. Advertising

  3. Victor Bazarov wrote:
    > Ioannis Vranos wrote:
    >> 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.



    Yes, I knew that. Anyone with something more specific?
     
    Ioannis Vranos, Mar 8, 2008
    #3
  4. Ioannis Vranos

    Jerry Coffin Guest

    In article <fqv80t$2j9o$>,
    says...
    > Victor Bazarov wrote:
    > > Ioannis Vranos wrote:
    > >> 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.

    >
    >
    > Yes, I knew that. Anyone with something more specific?


    Section 5.2.4.2

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.
     
    Jerry Coffin, Mar 9, 2008
    #4
  5. Ioannis Vranos

    Ian Collins Guest

    Ioannis Vranos wrote:
    > Victor Bazarov wrote:
    >> Ioannis Vranos wrote:
    >>> 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.

    >
    > Yes, I knew that. Anyone with something more specific?


    You've already asked on c.l.c, why ask again here?

    --
    Ian Collins.
     
    Ian Collins, Mar 9, 2008
    #5
  6. Jerry Coffin wrote:
    > In article <fqv80t$2j9o$>,
    > says...
    >> Victor Bazarov wrote:
    >>> Ioannis Vranos wrote:
    >>>> 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.

    >>
    >> Yes, I knew that. Anyone with something more specific?

    >
    > Section 5.2.4.2



    In C++03, section 5.2.4 is about "Pseudo destructor call". Nothing
    relevant ro my question there.
     
    Ioannis Vranos, Mar 9, 2008
    #6
  7. Ian Collins wrote:
    > Ioannis Vranos wrote:
    >> Victor Bazarov wrote:
    >>> Ioannis Vranos wrote:
    >>>> 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.

    >> Yes, I knew that. Anyone with something more specific?

    >
    > You've already asked on c.l.c, why ask again here?



    Because I am interested in both C95 and C++03.
     
    Ioannis Vranos, Mar 9, 2008
    #7
  8. Ioannis Vranos

    Ian Collins Guest

    Ioannis Vranos wrote:
    > Ian Collins wrote:
    >> Ioannis Vranos wrote:
    >>> Victor Bazarov wrote:
    >>>> Ioannis Vranos wrote:
    >>>>> 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.
    >>> Yes, I knew that. Anyone with something more specific?

    >>
    >> You've already asked on c.l.c, why ask again here?

    >
    >
    > Because I am interested in both C95 and C++03.


    C++ inherits this from C. The reference Jerry gave you was from the C
    standard.

    --
    Ian Collins.
     
    Ian Collins, Mar 9, 2008
    #8
  9. Ioannis Vranos

    Jerry Coffin Guest

    In article <fqvgtd$2kp$>,
    says...
    > Jerry Coffin wrote:
    > > In article <fqv80t$2j9o$>,
    > > says...
    > >> Victor Bazarov wrote:
    > >>> Ioannis Vranos wrote:
    > >>>> 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.
    > >>
    > >> Yes, I knew that. Anyone with something more specific?

    > >
    > > Section 5.2.4.2

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

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.
     
    Jerry Coffin, Mar 9, 2008
    #9
  10. Ioannis Vranos

    James Kanze Guest

    On 8 mar, 23:09, Ioannis Vranos <>
    wrote:
    > 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.

    --
    James Kanze (GABI Software) email:
    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
     
    James Kanze, Mar 9, 2008
    #10
  11. James Kanze wrote:
    > On 8 mar, 23:09, Ioannis Vranos <>
    > wrote:
    >> 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.



    Do you mean that all integer types, signed and unsigned, are required to
    not have padding bits?
     
    Ioannis Vranos, Mar 9, 2008
    #11
  12. On 2008-03-09 13:33, Ioannis Vranos wrote:
    > James Kanze wrote:
    >> On 8 mar, 23:09, Ioannis Vranos <>
    >> wrote:
    >>> 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.

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

    --
    Erik Wikström
     
    Erik Wikström, Mar 9, 2008
    #12
  13. Ioannis Vranos

    Jack Klein Guest

    On Sun, 09 Mar 2008 14:33:53 +0200, Ioannis Vranos
    <> wrote in comp.lang.c++:

    > James Kanze wrote:
    > > On 8 mar, 23:09, Ioannis Vranos <>
    > > wrote:
    > >> 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.

    >
    >
    > 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
     
    Jack Klein, Mar 9, 2008
    #13
  14. Ioannis Vranos

    James Kanze Guest

    On Mar 9, 1:33 pm, Ioannis Vranos <>
    wrote:
    > James Kanze wrote:
    > > On 8 mar, 23:09, Ioannis Vranos <>
    > > wrote:
    > >> 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.


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

    --
    James Kanze (GABI Software) email:
    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
     
    James Kanze, Mar 10, 2008
    #14
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ioannis Vranos

    Minimum sizes of integral and floating point types

    Ioannis Vranos, Mar 8, 2008, in forum: C Programming
    Replies:
    9
    Views:
    345
    Richard Heathfield
    Mar 9, 2008
  2. Fred Zwarts
    Replies:
    5
    Views:
    796
    puzzlecracker
    Oct 8, 2009
  3. ceycey
    Replies:
    5
    Views:
    522
  4. Saraswati lakki
    Replies:
    0
    Views:
    1,350
    Saraswati lakki
    Jan 6, 2012
  5. Marco
    Replies:
    2
    Views:
    109
    Serhiy Storchaka
    Jul 16, 2013
Loading...

Share This Page