Java Reference
In-Depth Information
// Print some double constants
System.out.println("Max double = " + Double.MAX_VALUE);
System.out.println("Min double = " + Double.MIN_VALUE);
System.out.println("Positive infinity for double = " + Double.POSITIVE_INFINITY);
System.out.println("Negative infinity for double = " + Double.NEGATIVE_INFINITY);
System.out.println("Not-a-Number for double = " + Double.NaN);
System.out.println("Double takes " + Double.BYTES + " bytes");
}
}
anInt = 100
aLong = 200
aByte = 65
aShort = -902
aChar = A
aFloat = 10.98
aDouble = 899.89
Max double = 1.7976931348623157E308
Min double = 4.9E-324
Positive infinity for double = Infinity
Negative infinity for double = -Infinity
Not-a-Number for double = NaN
double takes 8 bytes
Binary Representation of Integers
Computers use the binary number system to work with data. All data in a binary system is stored using 1's and 0's.
Characters 1 and 0 are called bits (short for binary digit). They are the smallest units of information a computer can
work with. A group of 8 bits is called a byte or octet. Half a byte (i.e. a group of four bits) is called a nibble. A computer
uses data bus, a pathway, to send data from one part of the computer system to another. How much information can
be moved from one part to another at one time depends on the bit-width of the data bus. The bit-width of the data bus
on a particular computer is also known as word-size, and information contained in one word-size is simply referred to
as a word. Therefore, a word may refer to 16-bit or 32-bit or another bit-width depending on computer's architecture.
The long and double data types in Java take 64 bits. On a computer with a word-size of 32 bits, these two data types are
not treated atomically. For example, to write a value in a variable of long data type two write actions are performed,
one for each 32-bit half.
A decimal number can be converted to binary format using the following steps:
Divide the decimal number successively by 2
After each division, record the remainder. This will be 1 or 0.
Continue the above two steps until the result of the division is 0 (zero)
The binary number is formed by writing digits in the remainder column from bottom to top.
For example, the binary representation of decimal number 13 can be computed as shown in Table 3-5 .
 
 
Search WWH ::




Custom Search