Java Reference
In-Depth Information
Notice that in Figure D-1(a), starting at the second row, the second column contains the
quotient when the number in the previous row is divided by 2, and the third column
contains the remainder of that division. For example, in the second row, 65 / 2 ¼ 32, and
65 % 2 ¼ 1. In the third row, 32 / 2 ¼ 16 and 32 % 2 ¼ 0, and so on. For each row, the
number in the second column is divided by 2, the quotient is written in the row below
the current row, and the remainder appears in the third column. When using a figure
such as D-1 to find the binary representation of a nonnegative integer, we typically show
only the quotients and remainders, as shown in Figure D-1(b). You can write the binary
representation of the number, starting with the last remainder in the third column,
followed by the second to the last remainder, and so on. Thus:
65 10 ¼ 1000001 2 :
Next, consider the number 711. Figure D-2 shows the quotients and the remainders.
dividend/quotient
remainder
711
2
355
1 = a 0
2
177
1 = a 1
2
88
1 = a 2
2
44
0 = a 3
0 = a 4
2
22
2
11
0 = a 5
2
5
1 = a 6
2
2
1 = a 7
0 = a 8
1 = a 9
2
1
0
FIGURE D-2 Determining the binary representation of 711
From Figure D-2, it follows that:
711 10 ¼ 1011000111 2 :
Converting a Binary Number (Base 2) to Base 10
To convert a number from base 2 to base 10, we first find the weight of each bit in the
binary number, which is assigned from right to left. The weight of the rightmost bit is 0.
 
 
Search WWH ::




Custom Search