Sams Teach Yourself C++ in 21 Days

(singke) #1
Working with Numbers: Binary and Hexadecimal 815

A


1 × 11
1 × 22
1 × 44
0 × 80
1 × 16 16
0 × 32 0
1 × 64 64
1 × 128 128
1 × 256 256
0 × 512 0
0 × 1024 0
0 × 2048 0
1 × 4096 4,096
1 × 8192 8,192
0 × 16384 0
1 × 32768 32,768
Total 45,527

Converting this to hexadecimal requires a chart with the hexadecimal values.
Column 5 4321
Power 164 163 162 161 160
Value 65536 4096 256 16 1

The number is less than 65,536, so you can start with the fourth column. There are
eleven 4096s (45,056), with a remainder of 471. There is one 256 in 471 with a remain-
der of 215. There are thirteen 16s (208) in 215 with a remainder of 7. Thus, the hexadec-
imal number is B1D7.
Checking the math:
B (11) * 4096 = 45,056
1 * 256 = 256
D (13) * 16 = 208
7 * 1 = 7
Total 45,527

29 0672327112_app_a.qxd 11/19/04 12:30 PM Page 815

Free download pdf