0% found this document useful (0 votes)
2 views18 pages

Review of Number Systems

The document provides an overview of number systems including decimal, binary, octal, and hexadecimal, along with their conversions and representations. It explains the concepts of unsigned and signed numbers, positional number representation, and the processes for converting between different number systems. Additionally, it covers the conversion of decimal fractions to binary and fixed-point numbers, illustrating the methods with examples.

Uploaded by

cactusvernal123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views18 pages

Review of Number Systems

The document provides an overview of number systems including decimal, binary, octal, and hexadecimal, along with their conversions and representations. It explains the concepts of unsigned and signed numbers, positional number representation, and the processes for converting between different number systems. Additionally, it covers the conversion of decimal fractions to binary and fixed-point numbers, illustrating the methods with examples.

Uploaded by

cactusvernal123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Review of Number Systems

• Number systems – Decimal, Binary,


Hexadecimal, Octal .
• Conversions - decimal, binary.
• 1’s and 2’s complements.

Stephen Brown, Zvonko Vranesic, “Fundamentals of Digital


logic with Verilog Design”, Tata McGraw Hill Publishing
Company Limited, Special Indian Edition
Unsigned Numbers
• Numbers that are positive only are called unsigned numbers, and
numbers that can also be negative are called signed numbers.
• In the familiar decimal system:
• a number consists of digits that have 10 possible values from 0 to 9.
• each digit represents a multiple of a power of 10.
• For example, the number 8547 represents 8 × 103 + 5 × 102 + 4 × 101
+ 7 × 100.
• But, we do not normally write the powers of 10 with the number,
because they are implied by the positions of the digits.

Stephen Brown, Zvonko Vranesic, “Fundamentals of Digital


logic with Verilog Design”, Tata McGraw Hill Publishing
Company Limited, Special Indian Edition
Positional Number Representation
• In general, a decimal integer, D is expressed by an n-tuple comprising n
decimal digits as below,
D = dn−1dn−2 ・ ・ ・ d1d0
• V(D) represents the value
V(D) = dn−1 × 10n−1 + dn−2 × 10n−2 +・ ・ ・+d1 × 101 + d0 × 100
𝑛−1

𝑉(𝐷) = ෍ 𝑑𝑖 ×10𝑖
𝑖=0
• This is referred to as the positional number representation.
• Because the digits have 10 possible values and each digit is weighted as a power of 10
• we may say that decimal numbers are base-10, or radix-10 numbers.
• But in digital circuits it is not practical to use digits that can assume 10
values. Stephen Brown, Zvonko Vranesic, “Fundamentals of Digital
logic with Verilog Design”, Tata McGraw Hill Publishing
Company Limited, Special Indian Edition
Binary Number System
• In digital systems we use the binary, or base-2 or radix-2 number system in
which digits (bi) can be 0 or 1. Each binary digit is called a bit.
• Using positional number representation, a binary number can be written as,
B = bn−1bn−2 ・ ・ ・ b1b0
• And B represents an integer that has the decimal value V(B) as,
V(B) = bn−1 × 2n−1 + bn−2 × 2n−2 +・ ・ ・+b1 × 21 + b0 × 20
𝑛−1

𝑉(𝐵) = ෍ 𝑏𝑖 ×2𝑖
𝑖=0
• For example, the binary number 1010 represents the value
V = 1 × 23 + 0 × 22 + 1 × 21 + 0 × 20
Stephen Brown, Zvonko Vranesic, “Fundamentals of Digital
logic with Verilog Design”, Tata McGraw Hill Publishing
Company Limited, Special Indian Edition
Contd..
• We can indicate the radix as a subscript when there is potential for
confusion.
• So, 1010 is a base-2 number, and we shall write it as (1010)2.
• Evaluating the preceding expression for V
• => V = 1 × 23 + 0 × 22 + 1 × 21 + 0 × 20 = 8 + 4 + 1 = 10.
• Hence (1010)2 = (10)10 ; (1111)2 = (15)10.
• In general, using n bits allows representation of integers in the range 0
to 2n −1

Stephen Brown, Zvonko Vranesic, “Fundamentals of Digital


logic with Verilog Design”, Tata McGraw Hill Publishing
Company Limited, Special Indian Edition
Contd..
• In a binary number the right-most bit is usually referred to as the least-
significant bit (LSB).
• The left-most bit of an unsigned integer, which has the highest power
of 2 associated with it, is called the most-significant bit (MSB).
• In digital systems it is often convenient to consider several bits
together as a group.
• A group of four bits is called a nibble
• A group of eight bits is called a byte.

Stephen Brown, Zvonko Vranesic, “Fundamentals of Digital


logic with Verilog Design”, Tata McGraw Hill Publishing
Company Limited, Special Indian Edition
Conversion between Decimal and Binary
Numbers
• A binary number is converted into a decimal number simply by applying the previous
equation and evaluating it using decimal arithmetic.
• Ex. (1110)2 = (1 × 23 + 1 × 22 + 1 × 21 + 0 × 20)10 = (8 + 4 + 2)10 = (14)10
• Converting a decimal number into a binary number is not quite as straightforward.
• The conversion can be performed by successively dividing the decimal number by 2 as
follows.
• Suppose that a decimal number D = dk−1 ・ ・ ・ d1d0, with a value V, is to be converted
into a binary number B = bn−1 ・ ・ ・ b2b1b0.
• Thus V = bn−1 × 2n−1 +・ ・ ・+b2 × 22 + b1 × 21 + b0
• If we divide V by 2, the result is
V/2= bn−1 × 2n−2 +・ ・ ・+b2 × 21 + b1 + b0/2
• The quotient of this integer division is bn−1 ×2n−2 +・ ・ ・+b2 ×2+b1, and the remainder
is b0. Stephen Brown, Zvonko Vranesic, “Fundamentals of Digital
logic with Verilog Design”, Tata McGraw Hill Publishing
Company Limited, Special Indian Edition
Contd..
• The quotient of this integer division is bn−1 ×2n−2 +・
・ ・+b2 ×2+b1, and the remainder is b0.
• If the remainder is 0, then b0 = 0; if it is 1, then b0 = 1.
• We can see that the quotient is just another binary
number but with n − 1 bits rather than n bits.
• Now, dividing the quotient by 2 yields the remainder
b1 and the new quotient is bn−1 × 2n−3 +・ ・ ・+b2
• Continuing the process of dividing the new quotient
by 2, and determining one bit in each step, will
produce all bits of the binary number.
• The process continues until the quotient becomes 0.
• The Figure illustrates the conversion process, using
the example (857)10 = (1101011001)2.
• Note that the least-significant bit (LSB) is generated
first and the most significant bit (MSB) is generated
last. Stephen Brown, Zvonko Vranesic, “Fundamentals of Digital
logic with Verilog Design”, Tata McGraw Hill Publishing
Company Limited, Special Indian Edition
Octal and Hexadecimal Representations
• The positional number representation can be used for any radix. If the radix
is r, then the number say K can be written as,
K = kn−1kn−2 ・ ・ ・ k1k0
has the value,
𝑛−1

𝑉(𝐾) = ෍ 𝑘𝑖𝑟 𝑖
𝑖=0
• Our interest is limited to those radices that are most practical.
• We will use decimal numbers because they are used by people
• we will use binary numbers because they are used by computers.
• In addition, two other radices are also useful—8 and 16.
• Numbers represented with radix-8 are called octal numbers
• Radix-16 numbers are called hexadecimal
Stephen Brown, numbers.
Zvonko Vranesic, “Fundamentals of Digital
logic with Verilog Design”, Tata McGraw Hill Publishing
Company Limited, Special Indian Edition
Contd..
• In octal representation the digit values
range from 0 to 7.
• In hexadecimal representation (often
abbreviated as hex), each digit can have
one of 16 values.
• The first ten are denoted the same as in the
decimal system, namely, 0 to 9.
• Digits that correspond to the decimal values
10, 11, 12, 13, 14, and 15 are denoted by the
letters, A, B, C, D, E, and F
• In computers the dominant number
system is binary.
• The reason for using the octal and
hexadecimal systems is that they serve
as a useful shorthand notation for binary
numbers.
Stephen Brown, Zvonko Vranesic, “Fundamentals of Digital
logic with Verilog Design”, Tata McGraw Hill Publishing
Company Limited, Special Indian Edition
Conversion between Octal and Binary
Numbers
• One octal digit represents three binary bits.
• Thus a binary number is converted into an octal number by:
1. Take as groups of three bits starting from LSB, and
2. Replacing each of the group with the corresponding octal digit.
• For example, 101011010111 is converted as

• which means that (101011010111)2 = (5327)8.

Stephen Brown, Zvonko Vranesic, “Fundamentals of Digital


logic with Verilog Design”, Tata McGraw Hill Publishing
Company Limited, Special Indian Edition
Contd..
• If the number of bits is not a multiple of three, then we can add 0s to
the left of the MSB.
• For example, consider, (10111011)2

• Hence, (10111011)2 = (273)8


• Conversion from octal to binary is just as straightforward
• each octal digit is simply replaced by three bits that denote the same value.

Stephen Brown, Zvonko Vranesic, “Fundamentals of Digital


logic with Verilog Design”, Tata McGraw Hill Publishing
Company Limited, Special Indian Edition
Conversion between hexadecimal and
Binary Numbers
• A hexadecimal digit represents four bits.
• Thus a binary number is converted into an hexadecimal number by:
1. Take as groups of four bits starting from LSB, and
2. Replacing each of the group with the corresponding hexadecimal digit.

• For example, a 16-bit binary number, (1010111100100101)2 can be


represented as,

• Hence, (1010111100100101)2 = (AF25)16


Stephen Brown, Zvonko Vranesic, “Fundamentals of Digital
logic with Verilog Design”, Tata McGraw Hill Publishing
Company Limited, Special Indian Edition
Contd..
• Zeros are added to the left of the MSB if the number of bits is not a multiple
of four.
• For example, (1101101000)2 = (368)16 because of the grouping

• Conversion from hexadecimal to binary involves straightforward


substitution of each hex digit by four bits that denote the same value.
• Binary numbers used in modern computers generally have 32 or 64 bits.
• Written as binary n-tuples (sometimes called bit vectors)
• Such numbers are awkward to deal with due to their length.
• However, it is much simpler to deal with them in the form of 8- or 16-digit hex
numbers.
Stephen Brown, Zvonko Vranesic, “Fundamentals of Digital
logic with Verilog Design”, Tata McGraw Hill Publishing
Company Limited, Special Indian Edition
Problem: Convert the decimal number 14959
into a hexadecimal number.
• Solution: An integer is converted into the hexadecimal representation
by successive divisions by 16, such that in each step the remainder is a
hex digit.
• Consider a four-digit number H = h3h2h1h0. Its value is
• V = h3 × 163 + h2 × 162 + h1 × 16 + h0
• If we divide this by 16, we obtain V/16
= h3 × 162 + h2 × 16 + h1 + h0/16
• Thus, the remainder gives h0.
• Finally, (14959)10 = (3A6F)16.
Stephen Brown, Zvonko Vranesic, “Fundamentals of Digital
logic with Verilog Design”, Tata McGraw Hill Publishing
Company Limited, Special Indian Edition
Problem: Convert the decimal fraction 0.8254
into binary representation.
• Solution: A binary fraction is represented as the bit pattern B = 0.b−1b−2 · · ·
b−m and its value is
• V = b−1 × 2−1 + b−2 × 2−2 +· · ·+b−m × 2−m
• Multiplying this expression by 2 gives
V × 2 = b−1 + b−2 × 2−1 +· · ·+b−m × 2−(m−1)
• Here, the left-most term is the first bit to the right of the radix point.
• The remaining terms constitute another binary fraction
• To convert a decimal fraction into a binary fraction,
• we multiply the decimal number by 2 and
• set the computed bit to 0 if the product is less than 1 and
• set it to 1 if the product is greater than or equal to 1.
• repeat this calculation until a sufficient number of bits are obtained to meet the
desired accuracy.
Stephen Brown, Zvonko Vranesic, “Fundamentals of Digital
logic with Verilog Design”, Tata McGraw Hill Publishing
Company Limited, Special Indian Edition
Contd.

• Thus, (0.8254)10 = (0.11010011 . . .)2.


• Note: It may not be possible to represent a decimal fraction with a
binary fraction that has exactly the same value.
Stephen Brown, Zvonko Vranesic, “Fundamentals of Digital
logic with Verilog Design”, Tata McGraw Hill Publishing
Company Limited, Special Indian Edition
Problem : Convert the decimal fixed point number
214.45 into a binary fixed point number.
• Solution: For the integer
part perform successive
division by 2 and we get
11010110
• For the fractional part
perform successive
multiplication by 2 and
we get 0111001 . .
• The complete
computation is presented
in Figure 3.44,
producing (214.45)10 =
(11010110.0111001 . .
.)2.
Stephen Brown, Zvonko Vranesic, “Fundamentals of Digital
logic with Verilog Design”, Tata McGraw Hill Publishing
Company Limited, Special Indian Edition

You might also like