promotion image of download ymail app

Why is the range of signed int in ANSI C from -32768 to 32767?

More exactly I want to ask why the range is more on the negative side? Why is it not like -32767 to 32768? Is it a convention or is there some logic behind it? Kindly explain.

3 Answers

  • cosimo
    Lv 5
    9 years ago
    Favorite Answer

    I've provided a link below to the Wikipedia definition of "2's Complement" numbering. I believe that provides the details you need.

    • Commenter avatarLogin to reply the answers
  • Anonymous
    9 years ago

    The value of an int (integer variable) that you are talking is about "signed int".

    By default, all the integer, character and float variables in ANSI C are made to hold signed values, meaning that the very frist bit (MSB) holds the sign of the variable or value.

    To make the variable hold only positive values use "unsigned int" or just "unsigned" for integer variables and then you can use the variable with values ranging from 0 to 65536.

    Note that, in ANSI C, using a 16 bit compiler the size of an integer variable is 2 bytes. And am sure, you are working on a basic 16 bit C compiler.

    Source(s): 10 years of experience in C / C++
    • Commenter avatarLogin to reply the answers
  • 9 years ago

    Signed integer take 2 Bytes of memory mean 16 Bits so 2 raise 16 = 65536


    Signed integer can store -1 to -32768 negative numbers= 32768

    Signed integer can store 0 to 32767 positive numbers= 32768



    Don't forget to mark as Best Answer.

    For more details visit this link.

    • Commenter avatarLogin to reply the answers
Still have questions? Get your answers by asking now.