1digital Number System
1digital Number System
Part-I
mbering System
ny number systems are in use in digital technology. The most common are the
cimal, binary, octal, and hexadecimal systems. The decimal system is clearly the
st familiar to us because it is a tool that we use every day. Examining some of its
aracteristics will help us to better understand the other systems. In the next few pages
shall introduce four numerical representation systems that are used in the digital
stem. There are other systems, which we will look at briefly.
Decimal
Binary
Octal
Hexadecimal
cimal System
e decimal system is composed of 10 numerals or symbols. These 10 symbols are 0,
2, 3, 4, 5, 6, 7, 8, 9. Using these symbols as digits of a number, we can express any
antity. The decimal system is also called the base-10 system because it has 10 digits.
3
102 101 100 10-1 10-2 10-3
000 =100 =10 =1 . =0.1 =0.01 =0.001
Least
st Significant Digit Decimal point Significant
Digit
en though the decimal system has only 10 symbols, any number of any magnitude
n be expressed by using our system of positional weighting.
cimal Examples
3.1410
5210
102410
6400010
nary System
he binary system, there are only two symbols or possible digit values, 0 and 1. This
se-2 system can be used to represent any quantity that can be represented in decimal
other base system.
nary Counting
e Binary counting sequence is shown in the table:
22 21 20 Decimal
0 0 0 0
0 0 1 1
0 1 0 2
0 1 1 3
1 0 0 4
1 0 1 5
1 1 0 6
1 1 1 7
0 0 0 8
0 0 1 9
0 1 0 10
0 1 1 11
1 0 0 12
1 0 1 13
1 1 0 14
1 1 1 15
e binary number system is the most important one in digital systems, but several
ers are also important. The decimal system is important because it is universally
ed to represent quantities outside a digital system. This means that there will be
uations where decimal values have to be converted to binary values before they are
ered into the digital system.
additional to binary and decimal, two other number systems find wide-spread
plications in digital systems. The octal (base-8) and hexadecimal (base-16) number
stems are both used for the same purpose- to provide an efficient means for
resenting large binary system.
tal System
e octal number system has a base of eight, meaning that it has eight possible digits:
,2,3,4,5,6,7.
3
162 161 160 16-1 16-2 16-3
=1/25
096 =256 =16 =1 . =1/16 =1/4096
6
Least
Hexa Decimal
st Significant Digit Significant
point
Digit
Part-II
Code Conversion
Converting from one code form to another code form is called code
conversion, like converting from binary to decimal or converting from
hexadecimal to decimal.
Binary-To-Decimal Conversion
Any binary number can be converted to its decimal equivalent simply by
summing together the weights of the various positions in the binary
number which contain a 1.
Binary Decimal
110112
24+23+01+21+20 =16+8+0+2+1
Result 2710
and
Binary Decimal
101101012
27+06+25+24+03+22+01+20 =128+0+32+16+0+4+0+1
Result 18110
You should have noticed that the method is to find the weights (i.e.,
powers of 2) for each bit position that contains a 1, and then to add them
up.
Decimal-To-Binary Conversion
Decimal Binary
4510 =32 + 0 + 8 + 4 +0 + 1
=25+0+23+22+0+20
Result =1011012
Octal Digit 0 1 2 3 4 5 6 7
Binary
000 001 010 011 100 101 110 111
Equivalent
Example:
100 111 0102 = (100) (111) (010)2 = 4 7 28
Hexadecimal Digit 0 1 2 3 4 5 6 7
Binary Equivalent 0000 0001 0010 0011 0100 0101 0110 0111
Hexadecimal Digit 8 9 A B C D E F
Binary Equivalent 1000 1001 1010 1011 1100 1101 1110 1111
Example:
Example:
Hexadecimal Binary/Octal
5A816 = 0101 1010 1000 (Binary)
= 010 110 101 000 (Binary)
Result = 2 6 5 0 (Octal)
Digital Number System
Part-III
Binary Codes
Binary codes are codes which are represented in binary system with
modification from the original ones. Below we will be seeing the following:
Example: The bit assignment 1001, can be seen by its weights to represent
the decimal 9 because:
1x8+0x4+0x2+1x1 = 9
2421 Code
This is a weighted code, its weights are 2, 4, 2 and 1. A decimal number is
represented in 4-bit form and the total four bits weight is 2 + 4 + 2 + 1 = 9.
Hence the 2421 code represents the decimal numbers from 0 to 9.
5211 Code
This is a weighted code, its weights are 5, 2, 1 and 1. A decimal number is
represented in 4-bit form and the total four bits weight is 5 + 2 + 1 + 1 = 9.
Hence the 5211 code represents the decimal numbers from 0 to 9.
Reflective Code
A code is said to be reflective when code for 9 is complement for the code
for 0, and so is for 8 and 1 codes, 7 and 2, 6 and 3, 5 and 4. Codes 2421,
5211, and excess-3 are reflective, whereas the 8421 code is not.
Sequential Codes
A code is said to be sequential when two subsequent codes, seen as
numbers in binary representation, differ by one. This greatly aids
mathematical manipulation of data. The 8421 and Excess-3 codes are
sequential, whereas the 2421 and 5211 codes are not.
Excess-3 Code
Excess-3 is a non weighted code used to express decimal numbers. The
code derives its name from the fact that each binary code is the
corresponding 8421 code plus 0011(3).
Gray Code
The gray code belongs to a class of codes called minimum change codes, in
which only one bit in the code changes when moving from one code to the
next. The Gray code is non-weighted code, as the position of bit does not
contain any weight. The gray code is a reflective digital code which has the
special property that any two subsequent numbers codes differ by only one
bit. This is also called a unit-distance code. In digital Gray code has got a
special place.
nsmission and storage of digital data, error detection and correction is required.
ew examples of codes which permit error detection and error correction after
Detecting Codes
data is transmitted from one point to another, like in wireless transmission, or it is
ored, like in hard disks and memories, there are chances that data may get
ed. To detect these data errors, we use special codes, which are error detection
ty codes, every data byte, or nibble (according to how user wants to use it) is
ed if they have even number of ones or even number of zeros. Based on this
ation an additional bit is appended to the original data. Thus if we consider 8-bit
dding the parity bit will make it 9 bit long.
receiver side, once again parity is calculated and matched with the received parity
and if they match, data is ok, otherwise data is corrupt.
Sums
arity method is calculated over byte, word or double word. But when errors need to
cked over 128 bytes or more (basically blocks of data), then calculating parity is not
ht way. So we have checksum, which allows to check for errors on block of data.
are many variations of checksum.
mplest form of checksum, which simply adds up the asserted bits in the data,
detect a number of types of errors. In particular, such a checksum is not changed
le of Checksum : Given 4 bytes of data (can be done with any number of bytes):
2h, 3Fh, 52h
st the Checksum byte simply add it to the original group of bytes. This should give
0h.
he carry nibble again giving 00h. Since it is 00h this means the checksum means
es were probably not changed.
Correcting Codes
orrecting codes not only detect errors, but also correct them. This is used normally
ellite communication, where turn-around delay is very high as is the probability of
etting corrupt.
Error correcting codes) are used also in memories, networking, Hard disk, CDROM,
tc. Normally in networking chips (ASIC), we have 2 Error detection bits and 1 Error
ion bit.
ing Code
ing code adds a minimum number of bits to the data transmitted in a noisy channel,
ble to correct every possible one-bit error. It can detect (not correct) two-bits errors
annot distinguish between 1-bit and 2-bits inconsistencies. It can't - in general -
3(or more)-bits errors.
ea is that the failed bit position in an n-bit string (which we'll call X) can be
ented in binary with log2(n) bits, hence we'll try to get it adding just log 2(n) bits.
we set m = n + log2(n) to the encoded string length and we number each bit position
g from 1 through m. Then we place these additional bits at power-of-two positions,
1, 2, 4, 8..., while remaining ones (3, 5, 6, 7...) hold the bit string in the original
e set each added bit to the parity of a group of bits. We group bits this way: we
group for every parity bit, where the following relation holds:
1 groups bits 1, 3, 5, 7... while bit 2 groups bits 2, 3, 6, 7, 10... , bit 4 groups bits 4,
12, 13... and so on.
by definition, X (the failed bit position defined above) is the sum of the incorrect
bits positions (0 for no errors).
derstand why it is so, let's call X n the nth bit of X in binary representation. Now
er that each parity bit is tied to a bit of X: parity1 -> X 1, parity2 -> X2, parity4 -> X3,
-> X4 and so on - for programmers: they are the respective AND masks -. By
uction, the failed bit makes fail only the parity bits which correspond to the 1s in X,
h bit of X is 1 if the corresponding parity is wrong and 0 if it is correct.
hat the longer the string, the higher the throughput n/m and the lower the probability
o more than one bit fails. So the string to be sent should be broken into blocks
length depends on the transmission channel quality (the cleaner the channel, the
the block). Also, unless it's guaranteed that at most one bit per block fails, a
um or some other form of data integrity check should be added.
numeric Codes
nary codes that can be used to represent all the letters of the alphabet, numbers
athematical symbols, punctuation marks, are known as alphanumeric codes or
ter codes. These codes enable us to interface the input-output devices like the
ard, printers, video displays with the computer.
Code
stands for American Standard Code for Information Interchange. It has become a
standard alphanumeric code for microcomputers and computers. It is a 7-bit code
enting 27 = 128 different characters. These characters represent 26 upper case
(A to Z), 26 lowercase letters (a to z), 10 numbers (0 to 9), 33 special characters
mbols and 33 control characters.
bit code is divided into two portions, The leftmost 3 bits portion is called zone bits
e 4-bit portion on the right is called numeric bits.
it version of ASCII code is known as USACC-II 8 or ASCII-8. The 8-bit version can
ent a maximum of 256 characters.
C Code
C stands for Extended Binary Coded Decimal Interchange. It is mainly used with
omputer systems like mainframes. EBCDIC is an 8-bit code and thus accomodates
256 characters. An EBCDIC code is divided into two portions: 4 zone bits (on the
d 4 numeric bits (on the right).
Part-V
Floating
Point
Numbers
A real number or floating point number is a number which
has both an integer and a fractional part. Examples for
real real decimal numbers are 123.45, 0.1234, -0.12345,
etc. Examples for real binary numbers are 1100.1100,
0.1001, -1.001, etc. In general, floating point numbers
are expressed in exponential notation.
For example the decimal number
30000.0 can be written as 3 x 104.
312.45 can be written as 3.1245 x 102.
Similarly, the binary number 1010.001 can be written as
1.010001 x 103.
The general form of a number N can be expressed as
N = ± m x b±e.
Where m is mantissa, b is the base of number system
and e is the exponent. A floating point number is
represented by two parts. The number first part, called
mantissa, is a signed fixed point number and the second
part, called exponent, specifies the decimal or binary
position.
Binary Representation of Floating Point Numbers
A floating point binary number is also represented as in
the case of decimal numbers. It means that mantissa and
exponent are expressed using signed magnitude notation
in which one bit is reserved for sign bit.
Consider a 16-bit word used to store the floating point
numbers; assume that 9 bits are reserved for mantissa
and 7 bits for exponent and also assume that the
mantissa part is represented in fraction system. This
implies the assumed binary point is at the mantissa sign
bit immediate right.
Example
A binary number 1101.01 is represented as
Mantissa = 110101 = (1101.01)2 = 0.110101 X 24
Exponent = (4)10
Expanding mantissa to 8 bits we get 11010100
Binary representation of exponent (4)10 = 000100
The required representation is