The short data type requires two bytes of memory and stores an integer value in the range from -32,768 to +32,767.  Since the int data type requires four bytes of memory, why is the range for the int data type much more than twice as much as that of the short data type?  Be sure to show the math in your answer.

What will be an ideal response?


It is because of the number of bytes (bits) used in representing the numbers.  Since the short data type uses 2 bytes (16 bits), these 2 bytes can represent 65536 different values.  These range from -32,767 to + 32,768.  In other words in binary, 2 to the 16th power is 65536.

The int data type on the other hand uses 4 bytes (32 bits).  This number of bits can represent approximately 4 billion numbers (or - 2 billion to + 2 billion).  More precisely, 2 to the 32nd power is 4,294,967,296; therefore the range would be from -2,147,483,648 to +2,147,483,647.

Computer Science & Information Technology

You might also like to view...

The __________ specifies the instants in time at which the selection function is exercised.

A) ?decision mode ? B) ?medium-term scheduling C) ?ready state ? D) ?TAT

Computer Science & Information Technology

Structured programs can be easily broken down into routines or ____ that can be assigned to any number of programmers.

A. processes B. modules C. units D. pieces

Computer Science & Information Technology

Which of the following kinds of file utilities shrink the size of a file(s)?

A. unit B. file compression C. matrix D. conversion

Computer Science & Information Technology

If you specified ____ for a column when you created a table, then changing a value in a column to null is prohibited.

A. NOT NULL B. NULL C. CHAR D. NUMBER

Computer Science & Information Technology