Minimum sizes of integral and floating point types

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ioannis Vranos

    Minimum sizes of integral and floating point types

    About C95.

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

    #2
    Re: Minimum sizes of integral and floating point types

    Ioannis Vranos wrote:
    About C95.
    >
    Is there any mentioning in the standard about the number of usable bits
    of the various built in types, apart from char/signed char/unsigned char
    types? Or only about the minimum value ranges of them?
    1) C95 is not a standard. It is obsoleted by C99.

    2) Use C99 int32_t, int64_t, etc


    --
    jacob navia
    jacob at jacob point remcomp point fr
    logiciels/informatique

    Comment

    • Ioannis Vranos

      #3
      Re: Minimum sizes of integral and floating point types

      jacob navia wrote:
      Ioannis Vranos wrote:
      >About C95.
      >>
      >Is there any mentioning in the standard about the number of usable
      >bits of the various built in types, apart from char/signed
      >char/unsigned char types? Or only about the minimum value ranges of them?
      >
      1) C95 is not a standard.

      What do you mean it isn't a standard? Of course it is.

      It is obsoleted by C99.
      >
      2) Use C99 int32_t, int64_t, etc

      I want to program in C95.

      Comment

      • Ben Pfaff

        #4
        Re: Minimum sizes of integral and floating point types

        Ioannis Vranos <ivranos@nospam .no.spamfreemai l.grwrites:
        Is there any mentioning in the standard about the number of usable
        bits of the various built in types, apart from char/signed
        char/unsigned char types? Or only about the minimum value ranges of
        them?
        I am not sure exactly what you are after. If you want the number
        of bits in a given type, including any sign and padding bits,
        then CHAR_BIT*sizeof (type) will give you the answer. If you want
        the number of value bits, then you can figure it out from the
        type's range, although the calculation for that is not as simple.
        --
        char a[]="\n .CJacehknorstu" ;int putchar(int);in t main(void){unsi gned long b[]
        ={0x67dffdff,0x 9aa9aa6a,0xa77f fda9,0x7da6aa6a ,0xa67f6aaa,0xa a9aa9f6,0x11f6} ,*p
        =b,i=24;for(;p+ =!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
        2:{i++;if(i)bre ak;else default:continu e;if(0)case 1:putchar(a[i&15]);break;}}}

        Comment

        • Ioannis Vranos

          #5
          Re: Minimum sizes of integral and floating point types

          Ben Pfaff wrote:
          Ioannis Vranos <ivranos@nospam .no.spamfreemai l.grwrites:
          >
          >Is there any mentioning in the standard about the number of usable
          >bits of the various built in types, apart from char/signed
          >char/unsigned char types? Or only about the minimum value ranges of
          >them?
          >
          I am not sure exactly what you are after. If you want the number
          of bits in a given type, including any sign and padding bits,
          then CHAR_BIT*sizeof (type) will give you the answer. If you want
          the number of value bits, then you can figure it out from the
          type's range, although the calculation for that is not as simple.

          In other words my question is this. Does C95 specify that long must be
          at least 32 bits, or it only provides the minimum value ranges?

          Comment

          • Keith Thompson

            #6
            Re: Minimum sizes of integral and floating point types

            Ioannis Vranos <ivranos@nospam .no.spamfreemai l.grwrites:
            Ben Pfaff wrote:
            >Ioannis Vranos <ivranos@nospam .no.spamfreemai l.grwrites:
            >>Is there any mentioning in the standard about the number of usable
            >>bits of the various built in types, apart from char/signed
            >>char/unsigned char types? Or only about the minimum value ranges of
            >>them?
            >>
            >I am not sure exactly what you are after. If you want the number
            >of bits in a given type, including any sign and padding bits,
            >then CHAR_BIT*sizeof (type) will give you the answer. If you want
            >the number of value bits, then you can figure it out from the
            >type's range, although the calculation for that is not as simple.
            >
            In other words my question is this. Does C95 specify that long must be
            at least 32 bits, or it only provides the minimum value ranges?
            In C95 (or C89/C90), just as in C99, the predefined integral types are
            defined in terms of their minimal ranges. The range of long is at
            least -2147483647 .. +2147483647, which implies that it must have a
            least 32 bits (1 sign bit and at least 31 value bits). I don't think
            C95 uses the concepts of "value bits" and "padding bits"; those were
            introduced by C99.

            --
            Keith Thompson (The_Other_Keit h) <kst-u@mib.org>
            Nokia
            "We must do something. This is something. Therefore, we must do this."
            -- Antony Jay and Jonathan Lynn, "Yes Minister"

            Comment

            • Barry Schwarz

              #7
              Re: Minimum sizes of integral and floating point types

              On Sun, 09 Mar 2008 01:58:54 +0200, Ioannis Vranos
              <ivranos@nospam .no.spamfreemai l.grwrote:
              >About C95.
              >
              >Is there any mentioning in the standard about the number of usable bits
              >of the various built in types, apart from char/signed char/unsigned char
              >types? Or only about the minimum value ranges of them?
              For integer types you can compute the minimum number of usable bits
              from the ranges. For floating point types, you can compute the
              minimum number of usable bits from the minimum number of significant
              digits in each type.


              Remove del for email

              Comment

              • santosh

                #8
                Re: Minimum sizes of integral and floating point types

                Ioannis Vranos wrote:
                jacob navia wrote:
                >Ioannis Vranos wrote:
                >>About C95.
                >>>
                >>Is there any mentioning in the standard about the number of usable
                >>bits of the various built in types, apart from char/signed
                >>char/unsigned char types? Or only about the minimum value ranges of
                >>them?
                >>
                >1) C95 is not a standard.
                >
                >
                What do you mean it isn't a standard? Of course it is.
                Techinally the current C Standard is ISO 9899:1999, also called C99.

                However, in practise, C95 (the Standard ISO:9899:1989 + Amendment 1) is
                more widely implemented and used.
                >It is obsoleted by C99.
                >>
                >2) Use C99 int32_t, int64_t, etc
                >
                I want to program in C95.
                Perfectly fine.

                Coming to your question, the Standard actually defines the fundamental
                types in terms of their range, i.e., a signed char must hold values
                from -127 to 127, an unsigned long must hold values from 0 to
                4294967295 and so on. These details can be found in section 5.2.4.2 of
                the Standard.

                Only the types intN_t and uintN_t for values of N 8, 16, 32, and 64 are
                more rigorously defined. They must be exactly of that size (in bits)
                and must be represented in twos complement and must not have padding
                bits. But they are not relevant to you, as you are focused on C95.

                Although you can find out the number of usable (i.e. value) bits from
                the range of a type, it's not easy and even then there is no
                information on particular bits. For example bits 2 to 4 may be padding
                bits, or may not be, you can't easily tell.

                Comment

                • Richard Heathfield

                  #9
                  Re: Minimum sizes of integral and floating point types

                  Ioannis Vranos said:
                  jacob navia wrote:
                  >Ioannis Vranos wrote:
                  >>About C95.
                  >>>
                  >>Is there any mentioning in the standard about the number of usable
                  >>bits of the various built in types, apart from char/signed
                  >>char/unsigned char types? Or only about the minimum value ranges of
                  >>them?
                  >>
                  >1) C95 is not a standard.
                  >
                  >
                  What do you mean it isn't a standard? Of course it is.
                  Right.

                  Do you remember your first foray into comp.lang.c a few years ago? Remember
                  when you knew all the answers, and anyone that disagreed with you must be
                  some kind of idiot? Well, you learned better. Jacob Navia didn't.
                  >It is obsoleted by C99.
                  >>
                  >2) Use C99 int32_t, int64_t, etc
                  >
                  >
                  I want to program in C95.
                  I want to program in C, which for me means sticking to the common subset of
                  C90, C95, and C99. It is true that the current de jure standard is C99,
                  but until, at the very least, GNU and Microsoft offer conforming C99
                  implementations it will not be a de facto standard in the foreseeable
                  future. Note that lcc-win32, which Jacob Navia pushes even harder than he
                  pushes C99, is not C99-conforming.

                  --
                  Richard Heathfield <http://www.cpax.org.uk >
                  Email: -http://www. +rjh@
                  Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
                  "Usenet is a strange place" - dmr 29 July 1999

                  Comment

                  Working...