C90: minimum size of long

Discussion in 'C Programming' started by cpp_novice, Jul 19, 2006.

  1. cpp_novice

    cpp_novice Guest

    What is the minimum size of 'long' according to the ANSI 1990 standard?

    I thow that c99 requires longs to be atleast 32bits wide.

    Is there an electronic copy of the 1990 standard available online?
     
    cpp_novice, Jul 19, 2006
    #1
    1. Advertising

  2. cpp_novice

    Tom St Denis Guest

    cpp_novice wrote:
    > What is the minimum size of 'long' according to the ANSI 1990 standard?
    >
    > I thow that c99 requires longs to be atleast 32bits wide.
    >
    > Is there an electronic copy of the 1990 standard available online?


    "long" has always been at least upto 2^31 - 1 and down to -2^31.
    Unsigned long is at lesst 0...2^32 - 1

    Note that doesn't mean that

    a) It's incapable of representing things large than 2^31 or 2^32
    [resp.]

    b) Even if it can only represent upto 2^31/2^32 [resp] that it takes
    32 bits to do that [padding/trap bits].

    Tom
     
    Tom St Denis, Jul 19, 2006
    #2
    1. Advertising

  3. cpp_novice

    Flash Gordon Guest

    Tom St Denis wrote:
    > cpp_novice wrote:
    >> What is the minimum size of 'long' according to the ANSI 1990 standard?
    >>
    >> I thow that c99 requires longs to be atleast 32bits wide.
    >>
    >> Is there an electronic copy of the 1990 standard available online?

    >
    > "long" has always been at least upto 2^31 - 1 and down to -2^31.


    <pedant>
    Actually, it is down to at least -(2^31 - 1). I.e., -2^31 might not be
    valid, either due to being a trap on a 2s complement system (which I've
    not come across) or due to the use of 1s complement or sign-magnitude.
    </pedant>

    > Unsigned long is at lesst 0...2^32 - 1
    >
    > Note that doesn't mean that
    >
    > a) It's incapable of representing things large than 2^31 or 2^32
    > [resp.]
    >
    > b) Even if it can only represent upto 2^31/2^32 [resp] that it takes
    > 32 bits to do that [padding/trap bits].


    The rest is all correct as far as I can see.
    --
    Flash Gordon, living in interesting times.
    Web site - http://home.flash-gordon.me.uk/
    comp.lang.c posting guidelines and intro:
    http://clc-wiki.net/wiki/Intro_to_clc
     
    Flash Gordon, Jul 19, 2006
    #3
  4. cpp_novice

    pete Guest

    pete, Jul 19, 2006
    #4
  5. In article <-gordon.me.uk> Flash Gordon <> writes:
    ....
    > Actually, it is down to at least -(2^31 - 1). I.e., -2^31 might not be
    > valid, either due to being a trap on a 2s complement system (which I've
    > not come across) or due to the use of 1s complement or sign-magnitude.


    The Gould NP1.
    --
    dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
    home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
     
    Dik T. Winter, Jul 19, 2006
    #5
    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. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    707
    Eric Sosman
    Jul 8, 2003
  2. Daniel Rudy

    unsigned long long int to long double

    Daniel Rudy, Sep 19, 2005, in forum: C Programming
    Replies:
    5
    Views:
    1,218
    Peter Shaggy Haywood
    Sep 20, 2005
  3. Mathieu Dutour

    long long and long

    Mathieu Dutour, Jul 17, 2007, in forum: C Programming
    Replies:
    4
    Views:
    496
    santosh
    Jul 24, 2007
  4. Bartc

    C90 long long

    Bartc, Apr 6, 2008, in forum: C Programming
    Replies:
    26
    Views:
    927
  5. Jason Cavett

    Preferred Size, Minimum Size, Size

    Jason Cavett, May 23, 2008, in forum: Java
    Replies:
    5
    Views:
    12,652
    Michael Jung
    May 25, 2008
Loading...

Share This Page