4. Base conversion
• From any base-r to Decimal
• From Decimal to any base-r
• From Binary to either Octal or Hexadecimal
• From either Octal or Hexadecimal to Binary
5. Binary to octal or hexadecimal
Binary To Octal
Procedure:
• Partition binary number into groups of 3
digits
Example:
• (10110001101011.111100000110)2
= ______________ 8
6. Binary to octal or hexadecimal
10 110 001 101 011 . 111 100 000 110 2
8. Binary to octal or hexadecimal
Binary To Hexadecimal
Procedure:
• Partition binary number into groups of 4
digits
Example:
• (10110001101011.11110010)2
= ______________ 16
9. Binary to octal or hexadecimal
10 1100 0110 1011 . 1111 0010 2
10. Binary to octal or hexadecimal
10 1100 0110 1011 . 1111 0010 2
2 C 6 B . F 2 16
11. Octal or hexadecimal to binary
Octal To Binary
Procedure:
• Each octal digit is converted to its 3-
digit binary equivalent
Example: (673.124)8 = _____ 2
14. Octal or hexadecimal to binary
Hexadecimal to Binary
Procedure:
• Each hexadecimal digit is converted to
its 4-digit binary equivalent
Example: (306.D)16 = _____ 2
17. Any Other Number System
• In general, a number expressed in base-r has
r possible coefficients multiplied by powers of
r:
anrn + an-1rn-1 + an-2rn-2 +...+ a0r0 + a-1r-1 + a-2r-2 + ... + a-mr-m
where n = position of the coefficient
coefficients = 0 to r-1
19. Example
Base 5 number
coefficients: 0 to r-1 (0, 1, 2, 3, 4)
• (324.2)5
= 3 x 52 + 2 x 51 + 4 x 50 + 2 x 5-1
= 89.410
20. Example
Base 5 number
coefficients: 0 to r-1 (0, 1, 2, 3, 4)
• (324.2)5
= 3 x 52 + 2 x 51 + 4 x 50 + 2 x 5-1
= 89.410
• (4021)5
21. Example
Base 5 number
coefficients: 0 to r-1 (0, 1, 2, 3, 4)
• (324.2)5
= 3 x 52 + 2 x 51 + 4 x 50 + 2 x 5-1
= 89.410
• (4021)5
= 4 x 53 + 0 x 5 2 + 2 x 5 1 + 1 x 5 0
= 51110
23. Fixed-Point Representation
Unsigned Number Signed Number
leftmost bit is the leftmost bit
most significant bit represents the sign
Example: Example:
• 01001 = 9 • 01001= +9
• 11001 = 25 • 11001= - 9
24. Systems Used to Represent Negative Numbers
Signed-Magnitude Representation
A number consists of a magnitude and a symbol
indicating whether the magnitude is positive or
negative.
Examples:
+85 = 010101012 -85 = 110101012
+127 = 011111112 -127 = 111111112
25. Systems Used to Represent Negative Numbers
Signed-Complement System
• This system negates a number by taking its
complement as defined by the system.
• Types of complements:
– Radix-complement
– Diminished Radix-complement
26. Complements
• Diminished Radix • Radix Complement
Complement General Formula:
General Formula: r’s C of N = rn - N
(r-1)’s C of N = (rn - r-m) - N where
where n = # of bits
n = # of digits (integer) r = base/radix
m = # of digits (fraction) N = the given # in
r = base/radix base-r
N = the given # in base-r
29. Binary Codes
Code – a set of n-bit strings in which different
bit strings represent different numbers or
other things.
Binary codes are used for:
Decimal numbers
Character codes
30. Binary codes for decimal numbers
At least four bits are needed to represent
ten decimal digits.
Some binary codes:
BCD (Binary-coded decimal)
Excess-3
Biquinary
31. Binary codes for decimal numbers
BCD Excess-3 Code
straight assignment unweighted code
BCD + 3
of the binary
equivalent
weights can be
Biquinary Code
seven-bit code with
assigned to the error detection
binary bits according properties
to their position each decimal digit
consists of 5 0’s and
2 1’s
33. Differences between Binary and BCD
• BCDis not a number system
• BCD requires more bits than Binary
• BCD is less efficient than Binary
• BCD is easier to use than Binary
34. Coding vs Conversion
Conversion
bits obtained are binary digits
Example: 13 = 1101
Coding
bits obtained are combinations of 0’s and 1’s
Example: 13 = 0001 0011
35. Character Code
American Standard Extended Binary
Code for Information Coded Decimal
Exchange Interchange Code
7-bit code 8-bit code
contains 94 graphic last 4 bits range from
chars and 34 non- 0000-1001
printing chars
36. Gray code
• It is a binary number
Binary Gray
system where two Decimal
code code
successive values 0 000 000
differ in only one 1 001 001
2 010 011
digit, originally 3 011 010
designed to prevent 4 100 110
5 101 111
spurious output from 6 110 101
electromechanical 7 111 100
switches.
37. Number Representations
• No representation • Various methods
method is capable of can be used:
representing all real – Fixed-point number
system
numbers
– Rational number
• Most real values system
must be represented – Floating point
by an approximation number system
– Logarithmic number
system
38. Fixed-point representation
• It is a method used to represent integer
values.
• Disadvantages
– Very small real numbers are not clearly
distinguished
– Very large real numbers are not known
accurately enough
39. Floating-point Representation
• It is a method used to represent real
numbers
• Notation:
– Mantissa x Baseexponent
• Example
1 1000011 000100101100000000000000
= - 300.0