Let us say that you wanted to deal with the number 1,023,004 in your computer program. Would data type short be an appropriate choice?

A good answer might be:

No. Data of type short can be only in the range -32,768 to +32,767.

More Bits for More Range

Larger ranges of numeric values require more bits. The different sizes for integer data enable to programmer to pick an appropriate size for the data. Almost always you should pick a data type that has a range much greater than the largest number you expect to deal with. If you have just a few items of data, you save almost nothing in running time or in computer memory use by using a small sized data type.

Why do the small sized data types exist, then? Well, many real-world programs deal with massive amounts of data (billions of data items) and then using the smaller sizes may save significant amounts of space and time. But we will not use that much data in these notes. Usually you should use int or double for your numeric data.

When you write a program you do not have to know how to represent a number in bits. You can type the number just as you would on a typewriter. This is called a literal. Integer literals in a program are written as in a book, except there are no commas:

125          -32            16            0         -123987

All of the above examples are 32 bit int literals. A 64 bit long literal has a upper case 'L' or lower case 'l' at the end. However, NEVER use the lower case 'l' because it is easily confused with a digit '1'.

125L          -32L            16L            0l         -123987l

The last two examples are legal, but confusing.

QUESTION 7:

Is the following an integer literal?

197.0

Click Here after you have answered the question