|
Are numbers of fundamental importance to computer programs? A good answer might be:Yes. | ||||||||||||||||||||||||||||||
Numeric Primitive Data Types
Numbers are so important in Java that 6 of the 8 primitive data types are numeric types. There are both integer and floating point primitive types. Integer types have no fractional part; floating point types have a fractional part. On paper, integers have no decimal point, and floating point types do. But in main memory, there are no decimal points: even floating point values are represented with bit patterns. There is a fundamental difference between the method used to represent integers and the method used to represent floating point numbers.
Each primitive type uses a fixed number of bits.
This means that if you are using a particular data type
then the same number of bits will be used no matter what value is
represented.
For example,
all values represented using the
All values represented using the Values that are large in magnitude (negative or positive) need more bits to be represented. This is simular to writing out numbers on paper: large numbers need more digits. If a value needs more bits than a particular data type uses, then it cannot be represented using that data type. | ||||||||||||||||||||||||||||||
QUESTION 6:
Let us say that you wanted to deal with the number 1,023,004 in your
computer program.
Would data type | ||||||||||||||||||||||||||||||