Why integer range -32768 to 32768

Why integer range -32768 to 32768 and actual meaning of storage size 2 bytes ?

Questions by Ramkesh poshwal

Showing Answers 1 - 2 of 2 Answers

Varun Pratap Singh

  • May 15th, 2012
 

In C language, int takes 2 bytes. Now 2 bytes mean 16 bits.
One bit out of these 16 bits is for sign (+ or -) of integer.
So, remaining 15 bits will store data in form of 0 and 1. The maximum value in binary number system using 15 bits can be 32768 (or 2^15).

So an integer can store value from -32768 to +32767.
And this becomes from 0 to 65536 for unsigned integers, due to the reason that total usable bits become 16.

  Was this answer useful?  Yes

jbode

  • May 28th, 2012
 

[-32767,32767] is the minimum range for int, meaning a minimum size of 16 bits. Implementations may choose a wider size and range for integers.

That range covers most architectures, whether ones or twos complement.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions