240 likes | 278 Views
Dive into counting in binary, positional notation, hexadecimal numbers, negative numbers, and codes. Learn about 2's complement, signed numbers, ASCII codes, and more.
E N D
Number Systemsand Codes Discussion D4.1
Number Systems • Counting in Binary • Positional Notation • Hexadecimal Numbers • Negative Numbers
Counting in Binary BINARY HEX Position: 8 4 2 1 0 0 0 0 0 0 0 0 1 1 0 0 1 0 2 0 0 1 1 3 0 1 0 0 4 0 1 0 1 5 0 1 1 0 6 0 1 1 1 7 1 0 0 0 8
Counting in Binary BINARY HEX Position: 8 4 2 1 1 0 0 0 8 1 0 0 1 9 1 0 1 0 A 1 0 1 1 B 1 1 0 0 C 1 1 0 1 D 1 1 1 0 E 1 1 1 1 F
Counting in Binary BINARY DEC 128 64 32 16 8 4 2 1 0 0 1 1 0 1 0 0 52 1 0 1 0 0 0 1 1 163 1 1 1 1 1 1 1 1 255
Positional Notation N = P4P3P2P1P0 = P4b4 + P3b3 + P2b2 + P1b1 + P0b0 58410 = 5 x 102 + 8 x 101 + 4 x 100 = 500 + 80 + 4 = 584
Positional Notation N = P4P3P2P1P0 = P4b4 + P3b3 + P2b2 + P1b1 + P0b0 Binary 101102 = 1 x 24 + 0 x 23 + 1 x 22 + 1 x 21 + 0 x 20 = 16 + 0 + 4 + 2 + 0 = 2210
Positional Notation N = P4P3P2P1P0 = P4b4 + P3b3 + P2b2 + P1b1 + P0b0 Hex 3AF16 = 3 x 162 + A x 161 + F x 160 = 3 x 256 + 10 x 16 + 15 x 1 = 768 + 160 + 15 = 94310
Binary Hex 0110 1010 1000 6 A 8 1111 0101 1100 F 5 C
Questions What is the decimal value of 2435? 2x52+4x5+3 = 50+20+3 = 73
Ignore carry Negative Numbers Subtract by adding 73 -35 38 73 +65 138 10’s complement
Negative Numbers 10’s complement: Subtract from 100 Take 9’s complement and add 1 100 -35 65 99 -35 64 +1 65
Negative Numbers 2’s complement: Subtract from Take 1’s complement and add 1 100000000 01001101 10110011 11111111 -01001101 10110010 +1 10110011
Complement remaining bits Copy all bits to first 1 2’s complement Finding 2’s Complement 0 1 0 1 1 0 0 0 1 0 1 0 1 0 0 0
Negative NumberTake 2’s Complement 7510 = 4B16 = 01001011 -7510 = B516 = 10110101 FF -4B B4 +1 B5
Negative NumberTake 2’s Complement 110 = 0116 = 00000001 -110 = FF16 = 11111111 12810 = 8016 = 10000000 -12810 = 8016 = 10000000
Signed Numbers 4-bit: 8H = -8 to 7H = +7 1000 to 0111 8-bit: 80H = -128 to 7F = +127 16-bit: 8000H = -32,768 to 7FFFH = +32,767 32-bit: 80000000H = -2,147,483,648 to 7FFFFFFFH = +2,147,483,647
Questions What is the two’s complement of 00101100? 11010100
Questions What hex number represents the decimal number -40? 4010 = 2816 = 001010002 2’s comp 110110002 = D816
Gray Code Binary Gray Code Note that the least significant bit that can be changed without repeating a value is the bit that is changed 000 000 001 001 010 011 011 010 100 110 101 111 110 101 111 100
Binary-Coded Decimal (BCD) Use 4-bit binary numbers 0000 – 1001 to represent the decimal digits, 0 – 9. Note that the six hex values A – F, 1010 – 1111, are NOT valid BCD values. Example: 10010101 represents the hex value 9516 = 14910 However, as a BCD number it represents the decimal number 95.
Standard ASCII codes Dec 0 16 32 48 64 80 96 112 Hex 0 1 2 3 4 5 6 7 0 0 NUL DLE blank 0 @ P p 1 1 SOH DC1 ! 1 A Q a q 2 2 STX DC2 " 2 B R b r 3 3 ETX DC3 # 3 C S c s 4 4 EOT DC4 $ 4 D T d t 5 5 ENQ NAK % 5 E U e u 6 6 ACK SYN & 6 F V f v 7 7 BEL ETB ' 7 G W g w 8 8 BS CAN ( 8 H X h x 9 9 HT EM ) 9 I Y i y 10 A LF SUB * : J Z j z 11 B VT ESC + ; K [ k { 12 C FF FS , < L \ l | 13 D CR GS - = M ] m } 14 E SO RS . > N ^ n ~ 15 F SI US / ? O _ o DEL Standard ASCII Codes