GeekInterview.com
Series: Subject: Topic:
Question: 25 of 587

why integer range -32768 to 32768

why integer range -32768 to 32768 and actual meaning of storage size 2 bytes ?
Asked by: Ramkesh poshwal | Member Since Apr-2012 | Asked on: Apr 12th, 2012

View all questions by Ramkesh poshwal

Showing Answers 1 - 2 of 2 Answers
Varun Pratap Singh

Answered On : 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.

  
Login to rate this answer.
jbode

Answered On : May 28th, 2012

View all answers by jbode

[-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.

  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.