Short int and int

What is the difference between short int and int?

Questions by chaitanyawithu   answers by chaitanyawithu

Showing Answers 1 - 12 of 12 Answers

hi i hope this will be useful for u.

in 16 bit processor (Ex: 8086), int data type contains 2 bytes(16 bits) and short contains 1 bytes(8 bits).

in 32 bit processor (80486), int data type contains 4 bytes(32 bits) and short contains 2 bytes(16 bits).

thanks
kannan R

  Was this answer useful?  Yes

sumit

  • Feb 5th, 2012
 

Sorry to say that actually in most of C compiler short int is also of 16 bit and they are equivalent to each other.

  Was this answer useful?  Yes

The general idea is that short "always" represents a 16-bit integer, whereas int represents whatever the native word size is for that particular architecture (16- or 32-bit). "Always" is in scare quotes for those oddball architectures that use weird word sizes. All you can really be guaranteed of is that sizeof (char) <= sizeof (short) <= sizeof (int) <= sizeof (long).

Per the C standard, both int and short must represent *at least* the range [-32767,32767] and the unsigned versions must represent *at least* the range [0,65535], so both must be *at least* 16 bits wide.

  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