Digital Number Systems Guide
Digital Number Systems Guide
Data Types:
• The term data refer to factual information used for analysis or
reasoning.
• Data itself has no meaning, becomes information when it is
assigned a meaning.
• The register stored information i.e. in different formats
BITS,NUMBERS,& other binary coded information.
• Data types found in registers of digital computers:
1. Numbers
2. Letters of the alphabet
3. Other discrete symbols
4. Binary coded form made up of flipflops means 0’s and 1’s
DATA REPRESENTATION
NUMBER SYSTEMS:
• Number system is used to represent information in quantitative form.
• Some of the common number systems are binary, octal, decimal and
hexadecimal.
• A number system of base (also called radix) r is a system, which has r distinct
symbols for r digits.
• A string of these symbolic digits represents a number.
• To determine the value that a number represents, we multiply the number by
its place value that is an integer power of r depending on the place it is located
and then find the sum of weighted digits.
• Registers are made up of flip-flops and flip-flops are two-state devices that can
store only 1’s and 0’s.
DATA REPRESENTATION
• The numeric system we use daily is the decimal system. But machine
understands binary .
• Ex : decimal 7 converted binary with 4 bit code is 0111. means decimal 1 digit
is equal to binary 4 digits.
• A base of a number system or radix defines the range of values that a digit may
have.
• In the binary system or base 2, there can be only two values for each digit of a
number, either a "0" or a "1".
• In the octal system or base 8, there can be eight choices for each digit of a
number: "0", "1", "2", "3", "4", "5", "6", "7".
• In the decimal system or base 10, there are ten different values for each digit
of a number: "0", "1", "2", "3", "4", "5", "6", "7", "8", "9".
• In the hexadecimal system, we allow 16 values for each digit of a number: "0",
"1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", and "F".
• Where “A” stands for 10, “B” for 11 and so on.
DATA REPRESENTATION
Binary Numbers:
• In binary numbers we have two digits 0 and 1 and they can also be
represented, as a string of these two-digits called bits.
• The base of binary number system is 2.
• For example, 101010 is a valid binary number.
• DecimaI equivalent of a binary number.
• For converting the value of binary numbers to decimal equivalent we have to
find its value, which is found by multiplying a digit by its place value.
• For example,
• binary number 101010 is equivalent to:
DATA REPRESENTATION
Octal Numbers:
• An octal system has eight digits represented as 0,1,2,3,4,5,6,7.
• For finding equivalent decimal number of an octal number one has to find the
quantity of the octal number which is again calculated as:
• Octal Data (23.4)8
• (Please note the subscript 8 indicates it is an octal number, similarly, a subscript
2 will indicate binary, 10 will indicate decimal and H will indicate Hexadecimal
number, in case no subscript is specified then number should be treated as
decimal number or else whatever number system is specified before it.)
• Decimal equivalent of Octal Number:
DATA REPRESENTATION
Decimal Numbers:
Decimal number system has ten digits represented by 0,1,2,3,4.5,6,7,8 and 9.
Any decimal number can be represented as a string of these digits and since there
are ten decimal digits, therefore, the base or radix of this system is 10.
Thus, a string of number 234.5 can be represented as
Hexadecimal Numbers:
The hexadecimal system has 16 digits, which are represented I as
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. A number (F2)H is equivalent to
Number base conversions
• There are many methods or techniques which can be used to convert numbers
from one base to another.
We'll demonstrate here the following −
• Decimal to Other Base System
• Other Base System to Decimal
• Other Base System to Non-Decimal
• Shortcut method − Binary to Octal
• Shortcut method − Octal to Binary
• Shortcut method − Binary to Hexadecimal
• Shortcut method − Hexadecimal to Binary
Number base conversions
Decimal to Other Base(Binary) System:
• Steps Step 1 − Divide the decimal number to be converted by the value of the
new base.
• Step 2 − Get the remainder from Step 1 as the rightmost digit (least significant
digit) of new base number.
• Step 3 − Divide the quotient of the previous divide by the new base.
• Step 4 − Record the remainder from Step 3 as the next digit (to the left) of the
new base number.
• Repeat Steps 3 and 4, getting remainders from right to left, until the quotient
becomes zero in Step 3.
• The last remainder thus obtained will be the Most Significant Digit (MSD) of the
new base number
Number base conversions
Example − Subtraction
BINARY ARITHMETIC
Binary Multiplication
Binary multiplication is similar to decimal multiplication. It is simpler
than decimal multiplication because only 0s and 1s are involved.
There are four rules of binary multiplication.
BINARY ARITHMETIC
Binary Division
• Binary division is similar to decimal division. It is called as the long
division procedure
Example − Division
Subtraction by 1’s Complement
3
In subtraction by 1’s complement we subtract two binary numbers using
carried by 1’s complement. 9
The steps to be followed in subtraction by 1’s complement are:
• To write down 1’s complement of the subtrahend.
• To add this with the minuend.
• If the result of addition has a carry over then it is dropped and an 1 is added
in the last bit.
• If there is no carry over, then 1’s complement of the result of addition is
obtained to get the final result and it is negative.
Subtraction by 1’s Complement
Evaluate:
(i) 110101 – 100101
Solution:
Subtraction by 1’s Complement
Subtraction by 2’s Complement
With the help of subtraction by 2’s complement method we can easily
subtract two binary numbers.
The operation is carried out by means of the following steps:
• At first, 2’s complement of the subtrahend is found.
• Then it is added to the minuend.
• If the final carry over of the sum is 1, it is dropped and the result is
positive.
• If there is no carry over, the two’s complement of the sum will be
the result and it is negative.
The following examples on subtraction by 2’s complement will make the
procedure clear:
Subtraction by 2’s Complement
Evaluate:
(i) 110110 - 10110
• Solution:
• The numbers of bits in the subtrahend is 5 while that of minuend is 6. We
make the number of bits in the subtrahend equal to that of minuend by
taking a `0’ in the sixth place of the subtrahend.
• Now, 2’s complement of 010110 is (101101 + 1) i.e.101010. Adding this
with the minuend.
1 10110 Minuend
1 01010 2’s complement of subtrahend
Carry over 1 1 00000 Result of addition
After dropping the carry over we get the result of subtraction to be 100000.
Subtraction by 2’s Complement
Subtraction by 2’s Complement
(ii) 10110 – 11010
Solution:
• 2’s complement of 11010 is (00101 + 1) i.e.
00110. Hence
• Minued - 10110
• 2’s complement of subtrahend - 00110
• Result of addition - 11100
2’S complement :
1’s Complement of 0110 is 1001
Now add 1 to 1001 Therefore 1001
+ 1
-----------
1010
Solved Example
Floating point Representation
Floating-point number representation consists of two parts.
The first part of the number is a signed fixed-point number, which is termed as
mantissa, and the second part specifies the decimal or binary point position
and is termed as an Exponent.
The mantissa can be an integer or a fraction.
Please note that the position of decimal or binary point is assumed and it is not a
physical point, therefore, wherever we are representing a point it is only the
assumed position.
Example : A decimal + 12.34 in a typical floating point notation can be represented
in any of the following two forms:
Floating point Representation
This number in any of the above forms (if represented in BCD) requires 17 bits for
mantissa (I for sign and 4 each decimal digit as BCD) and 9 bits for exponent (I
for sign and 4 for each decimal digit as BCD).
Please note that the exponent indicates the correct decimal location.
In the first case where exponent is +2, indicates that actual position of the decimal
point is two places to the right of the assumed position, while exponent- 2
indicates that the assumed position of the point is two places towards the left
of assumed position.
The assumption of the position of point is normally the same in a computer
resulting in a consistent computational environment.
Floating-point numbers are often represented in normalized forms.
A floating point number whose mantissa does not contain zero as the most
significant digit of the number is considered to be in normalized form.
For example, a BCD mantissa + 370 which is 0 0011 0111 0000 is in normalized
form because these leading zero's are not part of a zero digit. On the other
hand a binary number 0 01100 is not in a normalized form.
Floating point Representation
The normalized form of this number is:
Arithmetic operations involved with floating point numbers are more complex in
nature, take longer time for execution and require complex hardware.
Yet the floating point representation is a must as it is useful in scientific
calculations. Real numbers are normally represented as floating point numbers
The following figure shows a format of a 32-bit floating-point number.
Floating point Representation
The characteristics of a typical floating-point representation of 32 bits in the above figure
are:
• Left-most bit is the sign bit of the number;
• Mantissa and should be in normalized form;
• The base of the number is 2, and
• A value of 128 is added to the exponent. (Why?) This is called a bias.
• In floating point numbers, for increasing both precision and range more number of bits
are needed. This can be achieved by using double precision numbers. A double precision
format is normally of 64 bits.
Institute of Electrical and Electronics Engineers (IEEE) is a society, which has created lot of
standards regarding various aspects of computer, has created IEEE standard 754 for
floating-point representation and arithmetic.
Floating point Representation
• According to IEEE 754 standard, the floating-point number is represented in
following ways:
• Half Precision (16 bit): 1 sign bit, 5 bit exponent, and 10 bit mantissa
• Single Precision (32 bit): 1 sign bit, 8 bit exponent, and 23 bit mantissa
• Double Precision (64 bit): 1 sign bit, 11 bit exponent, and 52 bit mantissa
• Quadruple Precision (128 bit): 1 sign bit, 15 bit exponent, and 112 bit mantissa
The structure of a floating point(real) number is as follows:
Only the mantissa and the exponent are stored. The base is implied (known
already) As it is not stored this will save memory capacity
Floating point Representation
IEEE standard:
There is a IEEE standard that defines the structure of a floating point number IEEE
Standard for Floating-Point Arithmetic (IEEE 754-2008) .
It defines 4 main sizes of floating point numbers 16, 32, 64 and 128 bit Sometimes
referred to as Half, Single, Double and Quadruple precision
A worked example:
In decimal first
250.03125
First convert the integer part of the mantissa into binary (as you have done
previously)
250 = 1111 1010
Now to convert the decimal portion of the mantissa
.03125
Floating point Representation
Floating Point Representation
Other Binary Codes
Binary Coded Decimal(BCD) code:
• In this code each decimal digit is represented by a 4-bit binary number.
BCD is a way to express each of the decimal digits with a binary code.
• In the BCD, with four bits we can represent sixteen numbers (0000 to
1111).
• But in BCD code only first ten of these are used (0000 to 1001). The
remaining six code combinations i.e. 1010 to 1111 are invalid in BCD.
As we know 2 binary bits can represent 2 power 2 = 4 different combinations,
3 bits can represent 2 power 3 = 8 combinations, and similarly, 4 bits can
represent 2 power 4 = 16 combinations.
To represent decimal digits into binary form we require 10 combinations, but
we need to have a 4-digit code.
One such simple representation may be to use first ten binary combinations
to represent the ten decimal digits. These are popularly known as Binary
Coded Decimals (BCD).
Other Binary Codes
Advantages of BCD Codes:
It is very similar to decimal system.
We need to remember binary equivalent of decimal numbers 0 to 9 only
Disadvantages of BCD Codes:
• The addition and subtraction of BCD have different rules.
• The BCD arithmetic is little more complicated.
• BCD needs more number of bits than binary to represent the
decimal number. So BCD is less efficient than binary.
Other Binary Codes
Solved Example
Alphanumeric Code
Alphanumeric codes:
• A binary digit or bit can represent only two symbols as it has only
two states '0' or '1'.
• But this is not enough for communication between two computers
because there we need many more symbols for communication.
• These symbols are required to represent 26 alphabets with capital
and small letters, numbers from 0 to 9, punctuation marks and other
symbols.
• The alphanumeric codes are the codes that represent numbers and
alphabetic characters.
• Mostly such codes also represent other characters such as symbol
and various instructions necessary for conveying information.
• An alphanumeric code should at least represent 10 digits and 26
letters of alphabet i.e. total 36 items.
• The following three alphanumeric codes are very commonly used for
the data representation.
• American Standard Code for Information Interchange (ASCII).
• Extended Binary Coded Decimal Interchange Code (EBCDIC).
Alphanumeric Code
ASCII code is a 7-bit code whereas EBCDIC is an 8-bit code. ASCII code is more
commonly used worldwide while EBCDIC is used primarily in large IBM
computers.
ASCII:
• This code allows the language encoding ie popularly used is ASCII.
• This code uses 7 bits to represent 128 characters, which include 32 non-
printing control characters, alphabets in lower and upper case, decimal
digits, and other printable characters that are available on your keyboard.
• Later as there was need for additional characters to be represented such as
graphics characters, additional special characters etc., ASCII was extended
to 8 bits to represent 256 characters (called Extended ASCII codes).
• There are many variants of ASCII, they follow different code pages for
language encoding, however, having the same format. The extended ASCII
codes are the codes used in most of the Microcomputers.
• The major strength of ASCII is that it is quite elegant in the way it represents
characters
Alphanumeric Code
• It is easy to write a code to manipulate upper/lowercase ASCII characters
and check for valid data ranges because of the way of representation of
characters.
• In the original ASCII the 8th bit (the most significant bit) was used for the
purpose of error checking as a check bit.
Extended Binary Coded Decimal Interchange Code (EBCDIC):
• It is a character-encoding format used by IBM mainframes.
• It is an 8-bit code and is NOT Compatible to ASCII.
• It had been designed primarily for ease of use of punched cards.
• This was primarily used on IBM mainframes and midrange systems such as
the AS/400.
• Another strength of EBCDIC was the availability of wider range of control
characters for ASCII.
• The character coding in this set is based on binary coded decimal, that is,
the contiguous characters in the alphanumeric range are represented in
blocks of 10 starting from 0000 binary to 1001 binary.
• Other characters fill in the rest of the range. There are four main blocks in
the EBCDIC code:
Alphanumeric Code