Largest possible value of Integer Constants

Discussion in 'C Programming' started by Nicholas, Sep 11, 2003.

  1. Nicholas

    Nicholas Guest

    How can I get the largest possible value of the Integer Constants and use it
    in the program for these types:
    1. int
    2. long
    3. unsigned short

    Thanks
     
    Nicholas, Sep 11, 2003
    #1
    1. Advertising

  2. Nicholas

    Tom Zych Guest

    Nicholas wrote:

    > How can I get the largest possible value of the Integer Constants and use it
    > in the program for these types:
    > 1. int
    > 2. long
    > 3. unsigned short


    #include <limits.h>

    INT_MAX, LONG_MAX, USHRT_MAX. And many more.

    See http://www-ccs.ucsd.edu/c/limits.html .

    --
    Tom Zych
    This email address will expire at some point to thwart spammers.
    Permanent address: echo '' | rot13
     
    Tom Zych, Sep 11, 2003
    #2
    1. Advertising

  3. Tom Zych wrote:
    > Nicholas wrote:
    >
    >
    >>How can I get the largest possible value of the Integer Constants and use it
    >>in the program for these types:
    >>1. int
    >>2. long
    >>3. unsigned short

    >
    >
    > #include <limits.h>
    >
    > INT_MAX, LONG_MAX, USHRT_MAX. And many more.
    >
    > See http://www-ccs.ucsd.edu/c/limits.html .
    >

    To the OP: also note that if portability is one of your objectives, you
    will want to use the minimal required values for those limits as
    specified in the ISO C standard (e.g. 65536 for UINT_MAX, etc.).

    > --
    > Tom Zych
    > This email address will expire at some point to thwart spammers.
    > Permanent address: echo '' | rot13

    Tom: nitpick. Your sig block looks ok, but is not (else it would have
    been automatically cut away by my newsreader...): you need to have an
    additional space character after those two dashes that start your sig block.

    --
    Bertrand Mollinier Toublet
    "In regard to Ducatis vs. women, it has been said: 'One is a sexy thing
    that you've just got to ride, even if it breaks down a lot, costs a lot
    of money, and will probably try to kill you'. However, nowadays I can't
    seem to remember which one is which." -- Peer Landa
     
    Bertrand Mollinier Toublet, Sep 11, 2003
    #3
  4. Nicholas

    Tom Zych Guest

    Bertrand Mollinier Toublet wrote:

    > Tom: nitpick. Your sig block looks ok, but is not (else it would have
    > been automatically cut away by my newsreader...): you need to have an
    > additional space character after those two dashes that start your sig block.


    Ah. I wondered why that space was there. Is that in an RFC or
    something?

    --
    Tom Zych
    This email address will expire at some point to thwart spammers.
    Permanent address: echo '' | rot13
     
    Tom Zych, Sep 11, 2003
    #4
  5. Nicholas

    Dan Pop Guest

    In <bjpv2n$lln4h$-berlin.de> Bertrand Mollinier Toublet <> writes:

    >Tom Zych wrote:
    >
    >> --
    >> Tom Zych
    >> This email address will expire at some point to thwart spammers.
    >> Permanent address: echo '' | rot13

    >Tom: nitpick. Your sig block looks ok, but is not (else it would have
    >been automatically cut away by my newsreader...): you need to have an
    >additional space character after those two dashes that start your sig block.


    Maybe he has, but his posting software was written in C ;-)

    Whether space characters that are written out immediately before a
    new-line character appear when read in is implementation-defined.

    Requiring a space right before the end of the line in the sig block
    separator was a brain dead idea in the first place. The posting software
    I've used until this year simply dropped that space.

    Dan
    --
    Dan Pop
    DESY Zeuthen, RZ group
    Email:
     
    Dan Pop, Sep 12, 2003
    #5
  6. Nicholas

    Tom Zych Guest

    Dan Pop wrote:

    > Whether space characters that are written out immediately before a
    > new-line character appear when read in is implementation-defined.


    Are you saying that's part of the C standard? In what context?
    It's hard to believe that's part of the standard - what if binary
    data happens to contain \x20\x0a?

    Anyway, my posting software (Netscape) isn't at fault. It precedes
    a sig with "-- \n". I put "--\n" inside my sig block to separate
    the sig I use for email from the sig I use when spammers will see
    it.

    --
    Tom Zych
    This email address will expire at some point to thwart spammers.
    Permanent address: echo '' | rot13
     
    Tom Zych, Sep 12, 2003
    #6
  7. Nicholas

    Ben Pfaff Guest

    Tom Zych <> writes:

    > Dan Pop wrote:
    >
    > > Whether space characters that are written out immediately before a
    > > new-line character appear when read in is implementation-defined.

    >
    > Are you saying that's part of the C standard? In what context?
    > It's hard to believe that's part of the standard - what if binary
    > data happens to contain \x20\x0a?


    It only applies to text streams, not binary streams.
    --
    "I'm not here to convince idiots not to be stupid.
    They won't listen anyway."
    --Dann Corbit
     
    Ben Pfaff, Sep 12, 2003
    #7
  8. Nicholas

    Tom Zych Guest

    Ben Pfaff wrote:

    > It only applies to text streams, not binary streams.


    ! I wasn't aware that C made a distinction. Have to read more...

    --
    Tom Zych
    This email address will expire at some point to thwart spammers.
    Permanent address: echo '' | rot13
     
    Tom Zych, Sep 12, 2003
    #8
    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. Dave
    Replies:
    3
    Views:
    437
    Jakob Bieling
    Nov 7, 2003
  2. gsterndale

    largest Regex match possible

    gsterndale, Jul 23, 2008, in forum: Ruby
    Replies:
    2
    Views:
    90
    gsterndale
    Jul 23, 2008
  3. Replies:
    1
    Views:
    140
    marss
    Feb 6, 2007
  4. John Reye
    Replies:
    14
    Views:
    789
    Tim Rentsch
    May 8, 2012
  5. Roy Smith
    Replies:
    1
    Views:
    147
    Dennis Lee Bieber
    Mar 1, 2013
Loading...

Share This Page