Professional Documents
Culture Documents
Chapter 1 and 2 Introduction To Digital System, Numbering System, Operation and Codes
Chapter 1 and 2 Introduction To Digital System, Numbering System, Operation and Codes
Binary 0~1
Octal 0~7
Hexadecimal 0 ~ 9, A ~ F
Significant Digits
Binary : 1 0 1 1 0 1
=> 300 + 90 + 7
=> 39710
Binary Number System (base 2)
Base 2 system: (0 , 1)
used to model the series of computer electrical signals
represent the information's.
0 represents the no voltage or an ‘off’ state
1 represents the presence of voltage or an ‘on’ state
Example: 1012
Weights in a binary
1 0 1 number are based on
power of two, that
increase from right to
right to left, beginning
1X 22 + 0 X 21 + 1 X 20 with 20
=> 4 + 0 + 1
=> 510
Binary to Decimal Conversion
Convert (10101101)2 to its decimal equivalent:
Binary 1 0 1 0 1 1 0 1
x x x x x x x x
Positional Values 27 26 25 24 23 22 21 20
Products 128 + 0 + 32 + 0 + 8 + 4 + 0 + 1
= 17310
Number Conversion
Decimal to Any Radix (Base) Conversion
1. INTEGER DIGIT:
Repeated division by the radix & record
the remainder
2. FRACTIONAL DECIMAL:
Multiply the number by the radix until
the answer is in integer
example :
25.3125 to Binary
Remainder
2 5 = 12 + 1
2
12 = 6 + 0
2
6 = 3 + 0
2
3 = 1 + 1
2
MSB LSB
1 = 0 + 1
2 2510 = 1 1 0 0 1 2
MSB LSB
Carry .0 1 0 1
0.3125 x 2 = 0.625 0
0.625 x 2 = 1.25 1
0.25 x 2 = 0.50 0
0.5 x 2 = 1.00 1
Answer: 1 1 0 0 1.0 1 0 1
0 + 0 = 0 Sum of 0 with a carry of 0
0 + 1 = 1 Sum of 1 with a carry of 0
1 + 0 = 1 Sum of 1 with a carry of 0
1 + 1 = 10 Sum of 0 with a carry of 1
Example:
11001 111
+ 1101 + 11
100110 ???
0-0=0
1-1=0
1-0=1
10 -1 = 1 0 -1 with a borrow of 1
Example:
1011 101
- 111 - 11
100 ???
0X0=0
0X1=0 Example:
1X0=0 100110
1X1=1 X 101
100110
000000
+ 100110
10111110
Use the same procedure as decimal division
1’s complements of binary numbers
Changing all the 1s to 0s and all the 0s to 1s
Example:
1 1 01 00 1 0 1 Binary number
0 0 10 11 0 10 1’s complement
2’s complements of binary numbers
2’s complement
Step 1: Find 1’s complement of the number
Binary # 11000110
1’s complement 00111001
Step 2: Add 1 to the 1’s complement
00111001
+ 1
00111010
Information about signed binary
numbers
A signed binary number consists of both sign and
magnitude information
The sign indicates whether a number is positive or
negative
The magnitude is the value of number
There are 3 forms in which a sign number can be
represented
Sign magnitude (least used)
1’s complement
2’s complement (most important because computer use 2’s
complement for negative number in arithmetic operation)
F.Y.I->Non-integer and very large or very small number
can be expressed in floating point form
110010.. …00101110010101
0 = positive
1 = negative ***** This is your basic
Integer format
Sign numbers
Left most is the sign bit
0 is for positive, and 1 is for negative
Sign-magnitude
0 0 0 1 1 0 0 1 = +25
sign bit magnitude bits
1 0 0 1 1 0 0 1 = -25
sign magnitude bits
1’s complement
The negative number is the 1’s complement of the
corresponding positive number
Example:
+25 is 00011001 -25 is 11100110
Sign numbers
2’s complement
Example:
+25 is 00011001
The negative number is the 2’s complement
of the corresponding positive number.
Thus, -25 in 2’s complement form is 11100111
Example:
Express +19 and -19 in
i. sign magnitude
ii. 1’s complement
iii. 2’s complement
Octal Number System (base 8)
Base 8 system: (0,1,………,7)
multiplication and division algorithms for conversion to and from
base 10
example : 7568 convert to decimal
Weights in a binary
7 5 6 number are based on
power of eight that
7X 82 + 5 X 81 + 6 X 80 increase from right to
=> 448 + 40 + 6 right to left, beginning
with 80
=> 49410
Readily converts to binary
Groups of three (binary) digits can be used to represent each octal number
example : 7568 convert to binary
7 5 6
111101110
2
Octal to Decimal Conversion
Convert 6538 to its decimal equivalent:
Octal Digits 6 5 3
x x x
Positional Values 8 2 81 8 0
Products 384 + 40 + 3
= 42710
Decimal to Octal Conversion
Convert 42710 to its octal equivalent:
427 / 8 = 53 R3 Divided by 8; R is LSD
53 / 8 = 6 R5 Divide Q by 8; R is next digit
6 / 8 = 0 R6 Repeat until Q = 0
6538
Decimal to Octal Conversion
Binary to Octal Conversion (vice
versa)
Grouping the binary position in
groups of three starting at the
least significant position.
Octal to Binary Conversion
Each octal number converts to 3 binary digits
mantissa exponent
Hexadecimal Number System (base 16)
HEXADECIMAL DECIMAL BINARY
0 0 0000
Base 16 system 1 1 0001
A 9 F
Weights in a hexadecimal
number are based on
10X 162 + 9 X 161 + 15 X 160 power of sixteen that
increase from right to right
=> 2560 + 144 + 15 to left,beginning with 160
=> 271910
Readily converts to binary
Groups of four (binary) digits can be used to represent each hexadecimal
number
example : A9F16 convert to binary
A 9 F
1010100111112
Hexadecimal to Decimal Conversion
Convert 3B4F16 to its decimal equivalent:
Hex Digits 3 B 4 F
x x x x
Positional Values 163 162 161 160
Products 12288 + 2816 + 64 +15
= 15,18310
Decimal to Hexadecimal Conversion
Convert 83010 to its hexadecimal equivalent:
830 / 16 = 51 R 14 = E in Hex
51 / 16 = 3 R3
3 / 16 = 0 R3
33E16
Binary to Hexadecimal Conversion
Binary to Hexadecimal Conversion (vice
versa)
Grouping the binary position in 4-bit
groups, starting from the least
significant position.
Binary to Hexadecimal Conversion
The easiest method for converting binary to
hexadecimal is using a substitution code
Each hex number converts to 4 binary digits
Number Conversion
Example:
Convert the following binary numbers to
their hexadecimal equivalent (vice versa).
a) 10000.12
b) 1F.C16
Answer:
Answer
a) 10.816
b) 00011111.11002
Digital Codes (1)
BCD (Binary Coded Decimal) / 8421
Code
Represent each of the 10 decimal digits (0~9)
as a 4-bit binary code.
Useful as keypad inputs, digital clocks, digital
thermometer and other devices with 7-
segment displays
Example:
Convert 15 to BCD.
1 5
0001 0101
Convert 10 to binary and BCD.
Digital Codes (2)
ASCII (American Standard Code for
Information Interchange) Code
Used to translate from the keyboard characters
to computer language
A world standard alphanumeric code for
microcomputers and computers
A 7-bit code representing 27 (128) diff. characters
(26 upper case, 26 lower case, 10 numbers, 33
special characters/symbol, 33 ctrl characters
8-bit version ASCII (USACC-II 8 or ASCII-8)
represent max. of 256 characters.
Digital Codes (3)
The Gray Code Decimal Binary Gray
Code
Only 1 bit changes
Can’t be used in
0 0000 0000
arithmetic circuits 1 0001 0001
Used in shaft 2 0010 0011
position encoders
3 0011 0010
Can convert from
Binary to Gray Code 4 0100 0110
and vice versa. 5 0101 0111
How to convert ?????
6 0110 0101
Reading Assignment
Excess-3 Code
Error Detecting and Correction Code
EBCDIC (Extended Binary Coded Decimal
Interchange) Code