Professional Documents
Culture Documents
Image/Video Information
Representation
Transmission Transmission
Compression
Audio Processing
Capture
• Moore’s Law
• Technology
• Compute requirements
• Design Automation
Number System
Traditional number system
• The possibilities
Decimal Octal
Binary Hexadecimal
Decimal number system
• Technique
Multiply each bit by 2n, where n is the ‘weight’ of the bit
The weight is the position of the bit, starting from 0 on the right
Add the results
• Technique
Multiply each bit by 8n, where n is the ‘weight’ of the digit
The weight is the position of the digit, starting from 0 on the right
Add the results
• Technique
Multiply each bit by 16n, where n is the ‘weight’ of the digit
The weight is the position of the digit, starting from 0 on the right
Add the results
• Technique
N divide by two, reminder is a0, quotient become N
Repeat above step to get subsequent digits
• Example: 5310 = ?2
2 53
2 26 1 a0 = 1 5310 = 1101012
2 13 0 a1 = 0
2 6 1 a2 = 1
2 3 0 a3 = 0
2 1 1 a4 = 1
0 1 a5 = 1
Octal to Binary
• Technique
Convert each octal digit to a 3-bit equivalent binary
representation
• Example: 7058 = ?2
7 0 5
7058 = 1110001012
Hexadecimal to Binary
• Technique
Convert each hexadecimal digit to a 4-bit equivalent binary
representation
• Example: 10AF16 = ?2
1 0 A F
10AF16 = 00010000101011112
Decimal to Octal
• Technique
N divide by 8, reminder is a0, quotient become N
Repeat above step to get subsequent digits
• Example: 123410 = ?8
8 1234
8 154 2 a0 = 2 123410 = 23228
8 19 2 a1 = 2
8 2 3 a2 = 3
0 2 a3 = 2
Decimal to Hexadecimal
• Technique
N divide by 16, reminder is a0, quotient become N
Repeat above step to get subsequent digits
• Example: 123410 = ?16
16 1234
16 77 2 a0 = 2 123410 = 4D216
16 4 13 a1 = D
0 4 a2 = 4
Binary to Octal
• Technique
Group bits in threes, starting on right
Convert to octal digits
• Example: 10110101112 = ?8
1 011 010 111
1 3 2 7
10110101112 = 13278
Binary to Hexadecimal
• Technique
Group bits in fours, starting on right
Convert to hexadecimal digits
2 B B
10101110112 = 2BB16
Octal to Hexadecimal
• Technique
Use binary as an intermediary
2 3 E
10768 = 23E16
Hexadecimal to Octal
• Technique
Use binary as an intermediary
• Example: 1F0C16 = ?8
1 F 0 C
1 7 4 1 4
1F0C16 = 174148
Assignment
1 0 1 1 1
1 1 0 1 1 1
+ 1 1 0 1 0 1
1 1 0 1 1 0 0
Subtraction in Binary
1 1 1
1 1 0 0 1 1
- 0 1 0 1 0 1
0 0 1 1 1 1 0
Decimal to binary conversion - fractions
• Negative Numbers
Sign and Magnitude Representation
1’s Complement Representation
2’s Complement Representation
Goal of negative number systems
• 1’s complement
Formula: 2n – 1 – x
• i.e. n =4, 24 – 1 – x = 15 – x
• In binary: (1111) – (b3b2b1b0)
• Just flip all the bits
• 2’s complement
Formula: 2n – x
• i.e. n =4, 24 – x = 16 – x
• In binary: (10000) – (0b3b2b1b0)
• Just flip all the bits and add 1
4-bit Example
b3 b2 b1 b0 Signed 1’ 2’
0 0 0 0 0 0 0 0
1 0 0 0 1 1 1 1
2 0 0 1 0 2 2 2
3 0 0 1 1 3 3 3
4 0 1 0 0 4 4 4
5 0 1 0 1 5 5 5
6 0 1 1 0 6 6 6
7 0 1 1 1 7 7 7
8 1 0 0 0 -0 -7 -8
9 1 0 0 1 -1 -6 -7
10 1 0 1 0 -2 -5 -6
11 1 0 1 1 -3 -4 -5
12 1 1 0 0 -4 -3 -4
13 1 1 0 1 -5 -2 -3
14 1 1 1 0 -6 -1 -2
15 1 1 1 1 -7 -0 -1
Range for n-bits
• 3 bit • 5 bit
Signed: -3, 3 Signed: -15, 15
1’s: -3, 3 1’s: -15, 15
2’s: -4, 3 2’s: -16, 15
• 6 bits • 8 bits
Signed: -31, 31 Signed: -127, 127
1’s: -31, 31 1’s: -127, 127
2’s: -32, 31 2’s: -128, 127
• Example: 4 – 3 = 1
410 = 01002
310 = 00112, – 310 = 11012
0 1 0 0
+ 1 1 0 1
1 0 0 0 1 1 (after discarding extra bit)
• Example: – 4 + 3 = – 1
410 = 01002 , – 410 = 11002
310 = 00112 ,
1 1 0 0
+ 0 0 1 1
1 1 1 1 Using 2’s Complement: 0000 + 1 = 1
So answer = -1
• Example: 4 – 3 = 1
410 = 01002
310 = 00112, – 310 = 11002 (1’s complement)
0 1 0 0 (4 in decimal)
+ 1 1 0 0 (12 in decimal or 15 – 3)
1 0 0 0 0 (16 in decimal or 15 + 1)
0 0 0 1 (after subtracting 2n – 1)
• Example: – 4 + 3 = – 1
410 = 01002 , – 410 = 10112 (1’s complement)
310 = 00112 ,
1 0 1 1 (11 in decimal or 15 – 4)
+ 0 0 1 1 (3 in decimal)
1 1 1 0 (14 in decimal or 15 – 1)
The value is in 1’s complement
• Fixed point
Agreement between writer and reader
Does not change during the program
Total number of digits remain same
• Example
Assuming 4 decimal digits can be represented and decimal point
after 2 digits
• 2300, 123, 1, 100 would represent 23.00, 1.23, 0.01, 1.00
Effectively multiplying a number by 100
Fixed point in binary
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
• No decimal point
Maximum range (0 to 65536) or (-32768 to 32767)
• Decimal point after 4 bits
Range -2048 to 2047 and 4 bits for fraction
• Decimal point after 8 bits
Range -256 to 255 and 8 bits for fraction
Electron mass =
Number of bytes in one peta byte
9.1093837015 x 10-31 kg
1125899906842624 ≈ 1015 bytes
3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 9 8 7 6 5 4 3 2 1 0
1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
s Exponent Mantissa
• Decimal number: 1
• Binary number: 1
• Normal scientific form: 1.0 x 20
• Sign: 0
• Mantissa: 000 0000 0000 0000 0000 0000
• Exponent: (127 + 0)10 = (127)10 = (011 1111 1)2
• Floating point number
0011 1111 1000 0000 0000 0000 0000 0000
0x3F800000
Example (continued)
https://www.h-Schmidt.net/FloatConverter/IEEE754.html
Number line
• E = 255
– If mantissa is 0: it represents infinity
– If mantissa is ≠: NaN, not a number
• Divide by 0, multiplication of infinity with zero
• E=0
– If mantissa is 0: number is 0
– If mantissa is ≠: denormal number
De-normal numbers
• Quantization issues
– Different rounding can lead to different results
– Different formats have different precision
– Accumulation of errors
• Hardware/computational cost
Addition/subtraction of Floating point
• BCD addition
• Algorithm
– Normal binary addition
– If output of a nibble is more than 9 or carry is generated by the
nibble: add 0110 to the nibble
– Carry pass from one nibble to another in both steps (1 and 2)
56 + 75
0 1 0 1 0 1 1 0
+ 0 1 1 1 0 1 0 1
1 1 0 0 1 0 1 1
+ 0 1 1 0 0 1 1 0
1 0 0 1 1 0 0 0 1
1 3 1
Other BCD representation
• Excess 3 code
0 0011
• Self complementing
1 0100
2 0101 • After addition of two numbers – need
3 0110 to add/subtract 3 to fix the final
4 0111 results
5 1000
6 1001
7 1010
8 1011
9 1100
Error resilient codes
0 00011
1 00101
2 00110
3 01001
4 01010
5 01100
6 10001
7 10010
8 10100
9 11000
Low power code: Gray code
0 0000
1 0001
2 0011
3 0010
4 0110
5 1110
6 1010
7 1011
8 1001
9 1000
Representing characters
• ASCII
– Using 8 bit number for each commonly used character
• UTF-8
– Compatible with ASCII
– Used 1 to 6 bytes
• UTF-16
Summary