Page 68 - PowerPoint Presentation
P. 68
CAVITE STATE UNIVERSITY
T3 CAMPUS
Department of Information Technology DCIT 25 – Data Structures and Algorithms
Think of a data type as the term “case of tomatoes”. You call the warehouse manager
and say that you need to reserve enough shelf space to hold five cases of tomatoes. The
warehouse manager knows how many shelves to reserve because he knows the size of a
case of tomatoes.
The same is true about data type. You tell the computer to reserve space for an integer
by using the data type int. The computer already knows how much memory to reserve to store
an integer.
The data type also tells the computer the kind of data that will be stored at the memory
location. This is important because computers manipulate data of some data types differently
than data of other data types. This is similar to how the warehouse manager treats a case of
paper plates differently than a case of tomatoes.
Choose the data type that best suits the data you want to store in memory, then use
the data type in a declaration statement to declare a variable.
A variable is a reference to the memory location that you reserve using the declaration
statement.
Data Type Size Description
short 2 bytes Used for small integers (range -32768 to 32767)
int 4 bytes Stores whole numbers without decimal
long 4 bytes Used for large integers
char 1 byte Stores a single character/letter/number or ASCII Values
float 4 bytes Stores fractional numbers, containing one more decimal.
Sufficient for storing 7 decimal digits.
double 8 bytes Stores fractional numbers, containing one or more
decimal. Sufficient for storing 15 decimal digits.
boolean 1 byte Stores true or false values.
QUIZ 2. Binary Numbering System
Instruction: Solve and convert the following, show complete solution (2pts each):.
1. 101010011102 - __________________10
2. ABC78916 - __________________8
3. ABC78916 - __________________10
4. 2015610 - _________________2
5. 1010111010111101011100002 - ________________16
6. 778 - _______________2
7. 102410 - _______________2
8. 102310 - _________________16
9. 5468 - ________________16
10. 54616 - _________________8
Page | 15