Académique Documents
Professionnel Documents
Culture Documents
02 NUMBERS Page 1
Positional Numbers
528.4610 = (5 x 102) + (2 x 101) + (8 x 100) + (4 x 10-1) + (6 x 10-2)
527.468 = (5 x 82) + (2 x 81) + (7 x 80) + (4 x 8-1) + (6 x 8-2) 528.465 = illegal why? 101011.112 = (1 x 25) + (0 x 24) + (1 x 23) + (0 x 22) + (1 x 21) + (1 x 20) + (1 x 2-1) + (1 x 2-2)
02 NUMBERS Page 2
Binary Numbers
101011.112 = (1 x 25 ) + (0 x 24 ) + (1 x 23 ) + (0 x 22 ) + (1 x 21 ) + (1 x 20 ) + (1 x 2-1 ) + (1 x 2-2 ) Convert to Base 10: = 32 + 0 + 8 + 0 + 2 + 1 + + = 43.7510
02 NUMBERS Page 3
Hexadecimal
Commonly used for binary data
1 hex digit == 4 binary digits (bits)
Other Codes
BCD ASCII Gray
02 NUMBERS Page 5
2
0 0 1 0
4
0 1 0 0
9
1 0 0 1
6
0 1 1 0
1 0 0 1 1 1 0 0 0 0 0 02
02 NUMBERS Page 6
Binary Codes
02 NUMBERS Page 7
Binary Codes
Number 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Gray Code 0000 0001 0011 0010 0110 0111 0101 0100 1100 1101 1111 1110 1010 1011 1001 1000
Gray Code
02 NUMBERS Page 8
02 NUMBERS Page 9
Binary Addition
0+0=0 0+1=1 1+0=1 1 + 1 = 0 and carry 1 to the next column
Examples:
Carries
1 1 1
02 NUMBERS Page 10
1 1
Carries
If the operands are unsigned, you can use the final carry-out as the MSB of the result. Adding 2 k bit numbers k+1 bit result
02 NUMBERS Page 11
If you dont want a 5-bit result, just keep the lower 4 bits. This is insufficient to hold the result (16). It rolls over back to 0.
02 NUMBERS Page 12
Codes - Summary
Bits are bits
Modern digital devices represent everything as collections of bits A computer is one such digital device
Text (ASCII) Computer programs (C code, assembly code, machine code) Sound (.wav, .mp3, ) Pictures (.jpg, .gif, .tiff)
02 NUMBERS Page 13
Addition - Summary
Add binary numbers just like any other numbers
digit-by-digit addition carries propagate to next column to left