173k views
2 votes
What is the range of values that a short can represent?

a. 0 to 256
b. -127 to 128
c. Math.pow(-2.0,15.0) to (Math.pow(2.0,15.0) -1)
d. 0 to Math.pow(2.0,16.0)

User Windwalker
by
5.5k points

1 Answer

3 votes

Answer:

c. Math.pow(-2.0,15.0) to (Math.pow(2.0,15.0) -1).

Step-by-step explanation:

short represents a 16-bit signed integer. short is used to save memory because it occupies less space than integers where integers occupy 4 bytes short occupies 2 bytes.

Since it is signed so first bit is used to represent the sign if 0 then positive and 1 then the integer is negative.We are left with 15 bits.

So the range is -2¹⁵ to 2¹⁵-1.

Hence the answer is option c.

User Toseef Zafar
by
6.0k points