We know that in 16bit compiler integer variable have 2bytes(16 bits).First MSB for sign and other 15bits for value.By converting this 15bit to value we can get only (-16384 to 16383).Then how can we get the range (-32768 to 32767)??.....pl ease help me to deal with this.
How to define the range of integer variable?
Collapse
X
-
-
your math was wrong
the output you got is equivalent to
pow(2,14)
try the mathe
pow(2,15)
you will get the answer for sure -
The range of values that fit into the various types is implementation dependent. The Standard requires each implementation to explicitly specify its integer ranges with the macros of header file limits.h. (Floating point ranges are specified in float.h.)
The Standard mandates a certain minimum range for each data type, but each implementation is free to make the ranges larger. These minimum ranges are described at the limits.h link.
"We know that in 16bit compiler integer variable have 2bytes(16 bits).First MSB for sign and other 15bits for value"
Do not assume any particular encoding scheme. How negative numbers are encoded and whether there is a sign bit are implementation dependent. Your code will be nonportable if you try to make use of special knowledge like that.Comment
Comment