Documente Academic
Documente Profesional
Documente Cultură
(4021.2)5 = 4 53 + 0 52 + 2 51 + 1 50 + 2 51 = (511.4)10
(10110001101011.111100000110)2
2 6 1 5 3 7 4 0 6
Thus, the equivalent octal number is (26153.7406)8
Conversion from binary to hexadecimal is similar,
except that the binary number is divided into groups of
four digits
Thus, for the binary number:
(10110001101011.11110010)2
We re-write:
(10 1100 0110 1011 . 1111 0010)2
2 C 6 B F 2
Thus, the equivalent hexadecimal number is (2C6B.F2)16
Converting from octal or hexadecimal to binary is done
by reversing the preceding procedure
Each octal digit is converted to its three-digit binary
equivalent
For example:
6 7 3 1 2 4
Similarly, each hexadecimal digit is converted to its
four-digit binary equivalent
For example:
3 0 6 D
Binary numbers are difficult to work with because they
require three or four times as many digits as their
decimal equivalents (binary 111111111111 is equivalent
to decimal 4095!)
However, digital computers use binary numbers, and it
is sometimes necessary for the human operator or user
to communicate directly with the machine by means of
such numbers
Therefore, humans can think in terms of octal or
hexadecimal numbers and then convert to binary, using
the methods of conversion discussed above, whenever
direct communication with the machine is needed
Therefore, as we discuss binary numbers in computers,
using octal or hexadecimal numbers simplify
communications between people as we need to use a
reduced number of digits
Thats why most computer manuals use either octal or
hexadecimal numbers to specify binary quantities
Usually, the use of hexadecimal numbers is preferred as
it can represent a byte with only two digits
Decimal numbers
Binary numbers
Hexadecimal numbers
Complements are used in digital computers to simplify
the subtraction operation
Simplifying operations leads to simpler, less expensive
circuits to implement the operations
We have two types of complements for each base-r
system:
The radix complement
Also called the complement
The diminished radix complement
Also called the ( 1) complement
Given a number in base having digits, the (
1) complement of is defined as 1
For decimal numbers, = 10 and 1 = 9, so the 9s
complement of a decimal number is 10 1
Thus, if we represent decimal numbers in 6 digits, then
= 6, and thus we have:
10 1 = 106 1 = 999999
This means that the 9s complement of a decimal
number is obtained by subtracting each digit of the
decimal number from 9
For example, the 9s complement of the decimal
numbers 546700 and 12398:
999999 546700 = 453299
999999 012398 = 987601
The same concept applies when dealing with binary
numbers (i.e., = 2)
Assume that = 4, then we have:
24 1 = 10000 2 1 = 1111
This means that the 1s complement of a binary number
is obtained by subtracting each digit of the binary
number from 1
However, notice that with binary numbers, as we
subtract from 1 we can have either 1 0 = 1 or 1
1 = 0, which causes the bit to change from 0 to 1 or
from 1 to 0, respectively
Therefore, the 1s complement of a binary number is
formed by changing 10 to 0s and 0s to 1s:
1 1011000 0100111
1 0101101 1010010
The 1 complement of octal and hexadecimal
numbers is obtained by subtracting each digit from 7 or
F (decimal 15), respectively
Given a number in base having digits, the
complement of is defined as for 0, and
as 0 for = 0
Note that the 1 is defined as 1 , and
therefore, if we add 1 to it we get:
[ 1 ] + 1 =
which is the complement
That is, the complement of a number can be
computed by just adding 1 to the 1
complement of
For example, the 9s complement of the 4-digit decimal
number 2389 is 9999 2389 = 7610, and directly the
10s complement will be 7611
Also, the 1s complement of binary 101100 is 010011,
and directly the 2s complement is 010011 + 1 =
010100
Note that for decimal numbers, the 10s complement of
a number is 10
10 is always represented as 1 followed by 0s
We always need to subtract from 10 to get the 10s
complement
Thus, another easy way of getting the 10s complement
of decimal numbers is by leaving all least significant
0s unchanged, subtracting the first nonzero least
significant digit from 10, and subtracting all higher
significant digits from 9
For example:
10 012398 987602
10 246700 753300
The same concept applies with binary numbers:
2 1101100 0010100
2 0110111 1001001
If the number to be complemented contains a radix
point, we temporarily remove the radix point, we
complement the number, and finally restore the radix
point to its position
Note that the complement of the complement restores
the number to its original value:
The subtraction of two n-digit unsigned numbers in
base can be done as follows:
1. Add to the complement of
Mathematically, + = +
2. If , the sum will produce an end carry , which
can be discarded; what is left is the result
3. If < , the sum does not produce an end carry and is
equal to ( ), which is the complement of
. Thus, take the complement of the sum and
place a negative sign in front:
+ =
Using 10 complement, subtract 72532 3250