




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An in-depth exploration of the binary number system, focusing on the use of bits, place values, and various representation schemes for integers and real numbers. Topics include binary digits, place values, nibbles, big-endian and little-endian representation, binary addition and subtraction, and signed magnitude, one's complement, and two's complement notations.
Typology: Slides
1 / 8
This page cannot be seen from the preview
Don't miss anything!





The goal of this handout is to make you comfortable with the binary number system. We
Binary (^) means base 2 (the prefix
(^) bi ). Based on our earlier discussion of the decimal
will correlate your previous knowledge of the decimal number system to the binary
number system, the digits that can be used to count in this number system are 0 and 1.
number system. That will lay the foundations on which our discussion of various
The 0,1 used in the binary system are called
(^) bi nary digi t s (^) ( bits )
representation schemes for numbers (both integer and real numbers) will be based.
The bit (^) is the smallest piece of information that can be stored in a computer. It can have
one of two values 0 or 1. Think of a bit as a switch that can be either on or off. For
example,
Bit Value
Counting as we have been taught since kindergarten is based on the decimal number
system. (^) Decimal (^) means base 10 (the prefix
(^) dec ). In any number system, given the base
(often referred to as
(^) radix ), the number of digits that can be used to count is fixed. For
example in the base 10 number system, the digits that can be used to count are
Table 1. Interpreting Bit Values
From the hardware perspective, ON and OFF can be represented as voltage levels
Generalizing that for any base b, the first b digits (starting with 0) represent the digits that
(typically 0V for logic 0 and +3.3 to +5V for logic 1). Since only two values can be
are used to count. When a number
(^) ≥ (^) b has to be represented, the
(^) place values
(^) are used.
concept of place values is applicable here as well.stored in a bit, we combine a series of bits to represent more information. Again the
Example 1. Consider the number 1234. It can be represented as
Example 3. Consider the binary number 1101. It can be represented as
(^0)
(1)
(^0)
-^ Where: (^) 1 is in the thousand’s place
This expanded notation also gives you the means of converting binary numbers directly
2 is in the hundred’s place
into the equivalent decimal number.
3 is in the ten’s place
4 is in the one’s place.
The equation (1) is an expanded representation of 1234. The expanded representation has
Example 4. Consider the binary number 1101.101. It can be represented as:
the advantage of making the base of the number system explicit.
-
(4)
Example 2. Consider the number 1234.567. It is represented as
equivalent decimal number isThe same notation is applicable to real numbers represented in binary notation. The
- (2)
Where:
5 is in the tenth’s place
6 is in the hundredth’s place
7 is in the thousandth’s place
of importance:To represent larger numbers, we have to group series of bits. Two of these groupings are
In equation (2), the representation includes digits both to the left and to the right of the
A nibble is a group of four bits
decimal point.
A byte is a group of eight bits
byte are shown below in figure 1.
7 a 6 a 5 a 4 A 3 a 2 a 1 a 0 a
Figure 1. Byte
The (^) m ost (^) s ignificant (^) b
l east
s ignificant (^) b 7 a 2* (^) + a (^7) (^6) *** 2** (^) + a (^6) (^5) *** 2
form range will change.Answer: 0 to 255. Answer: 255 (^) words
. The size of words is dependent on the underlying processor, but is usually an
In the (^) big-endian
first). Conversely, in the
(^) little-endian bi-endian
The term (^) endian
Big-
Endian (^) and (^) Little-Endian
at the big end or the little end.
lsb
Byte (^) Big-Endian
(^) Little-Endian
Table 2. (^) Big-Endian versus Little-Endian Representation of 00000100 00000001
context, equation (5) refers to the
(^) little-endian ordering
If on the other hand, the
carried over
significant place).
Rule (^) Step (^) Result (^) Carry
Table 3
Carry 1
Carry 1
The byte is the smallest addressable unit in most computers. The key components of a
it (msb) is the bit with the highest place value, while the
it (lsb) denotes the bit position that has the lowest place value. To convert the
even number of bytes (typically 4 bytes).When we want to represent a value larger than 255, we have to group bytes together toNote: When we look at negative number representation using the same 8-bit number, theSelf- Exercise: What is the range of values represented by an 8-bit binary number?Self Exercise: What is the value of the bit pattern 11111111 ?byte to the equivalent integer number, the formula in (5) is used.
system, the byte with the largest significance is stored first (big-end-
system, the byte with the least significance is stored
system. The PowerPC system isbig-endian architecture. Most modern computers, including PCs, use the little-endianbyte in the sequence. Many mainframe computers, particularly IBM mainframes, use aThe sequencing of bytes to form larger numbers leads to the issue of which is the firstfirst (little-end-first). The number 1025 in binary is 00000100 00000001.
because it can understand both systems
comes from Swift's "Gulliver's Travels" via the famous paper "On Holy
Lilliputians, being very small, had correspondingly small political problems. TheWars and a Plea for Peace" by Danny Cohen, USC/ISI IEN 137, 1980-04-01. The
parties debated over whether soft-boiled eggs should be opened msb
The endian system may sometimes be used to represent the bit order within a byte. In this
of bits within the byte.
Example 5. Consider the operation 145 + 256decimal number system to the binary number system.Operations such as multiplication and division can be implemented using addition andFor any given number system, the operations of addition and subtraction are fundamental.
other digits in the next most significant place (or isplace position of the sum and the digit of higher significance is added along with thesummation operation results in 2 digits, the digit of lower significance is entered into thedigit, it is entered in the same place position in the sum.left. At each place position, the digits are added and if the resulting number is a singleThe algorithm works by starting at the least significant digit and working from right to
to the next most
The same principle applies to binary addition.
.Rules for Binary Addition
Bit Pattern (^) Number
The one’s complement notation represents a negative number by inverting the bits in
The two’s complement notation has the advantages that the sign of the number can be
each place. The one’s complement notation for a 4-bit number is shown in Table 5. Again
computed by looking at the msb. The addition operation can be used to perform
the limitations of the sign magnitude representation are not overcome (there are two bit
subtraction. Also, there is only one bit-pattern to represent ‘0’ so an extra number can be
patterns used to represent 0 and the addition operation cannot be used to perform
represented. Table 6 summarizes the 2’s complement notation for a 4-bit number.
inversionsubtraction). The one’s complement is important because it is very easy to perform the (^) operation (^) in hardware (^) and (^) it forms (^) the (^) basis (^) of computing (^) the (^) two’s
Bit Pattern (^) Number
complement.
Table 6
. Numbers using 2’s complement representation
Table 5
. Numbers using 1’s complement representation
table:Example 10. Consider the following operation 7 – 2. Substituting the bit patterns from the
table:Example 9. Consider the following operation 7 – 2. Substituting the bit patterns from the
The bit pattern 0101 is 5, which is the expected result.
The bit pattern 0100 is 4 but the result should by 5 0101.
number is larger. i.e. comparing the bit patterns alone does not provide any information as to whichThe limitation with the 2’s complement notation is that the bit patterns are not in order
The two’s complement notation builds on the one’s complement notation. The algorithm Two’s Complement
Excess Notation
goes as follows:
The excess notation is a means of representing both negative and positive numbers in a
Compute the 1’s complement
manner in which the order of the bit patterns is maintained. The algorithm for computing
Add 1 to the result to get the 2’s complement.
the excess notation bit pattern is as follows:
Add the excess value (
, where N is the number of bits used to represent theN-
Self-Exercise: What is the range of numbers that can be represented using the Excess-
N-
number) to the number.
notation?
Convert the resulting number into binary format.
Answer: 2
The (^2) N- is often (^) referred (^) to as (^) the (^) Magic (^) Number (^) for (^) computing
(^) the (^) excess
Bias Notation
numbers that can be represented using the excess-8 notation. representation of the number (except that there is no magic in it). Table 7 presents all the
b. (^) To represent real numbers.bit-pattern (the maximum value that can be held by 8 bits is 255). (^) To represent integers that are larger than the maximum value that can be held by a the value. If the number of places available to represent the number is limited to say four Consider a really large number 1,234,567. The number requires seven places to represent Large Integers
Table 7
. Numbers using the Excess-8 representation
the value associated with the digit. In this case, we will drop the last three digits ‘567’.places, certain digits have to be dropped. The selection of digits to be dropped is based on
The number of bits used to represent a code in excess-8 is 4 bits (
= 8). Also, the bit4-^
The resulting number is:
1111).patterns are in sequence (the largest number that can be represented has the bit pattern
Example 11. Consider the following operation 7 – 2. Substituting the bit patterns from the
The loss of ‘567’ is a loss of
(^) precision (^) but if the most significant digits were to be
table:
eliminated, say ‘123’, then the resulting number is
(^) which presents an even greater
loss of precision.
Rules for determining significance (integers):
The result of the addition operation is the bit-pattern used for 5 in binary. The excess
(^) never (^) significant if it precedes all the nonzero digits
notation. The excess notation will however play an important part in computing floating-notation representation however takes longer to compute than the 2’s complement
Self-Exercise: What are the significant digits in 0012340?
point representations.
Answer: 0012340
Number (^) Excess Number
(^) Bit Pattern
that matter), they must understand the representation that is being used. This is captured
by means of standards. At the end of this handout, we will discuss the IEEE standard
(^) x (^) is negative,
used for representing floating point numbers.
a. (^) Add (^) x (^) leading 0’s to the fractional part
Example12. What is the value represented by the bit pattern 11011110? Assume the radix
b. (^) Insert a radix point before the 0’s
point is between bit positions 3 and 4.
(^) x (^) places.
The bit pattern can be split into the integer part 1101 and the fractional part 1110.
(^7) bit.
Self-Exercise: Why does step 3 in the algorithm above not address adding zeroes?
hence, padding (adding leading 0’s or trailing 0’s) to the right is not needed.is 3. Moving the radix point right does not move to the right of the fraction part,Answer: From the excess table above, it is clear that the maximum positive exponent
Modified Significance Rules
Excess Number
(^) Actual Value
(^) Bit-Pattern
Rules for determining significance:
A ‘1’ bit is always significant
The bit '0' is significant if it lies between other significant bits
The bit '0' is
(^) never (^) significant if it precedes all 0’s, even if it follows an embedded
radix (in the example above, the radix is embedded between bit positions 3 and 4).
bitsThe bit '0' is significant if it follows an embedded radix point and other significant
Self-Exercise: What are the significant bits in the bit pattern00.010000?
Table 10
. Excess-4 Conversion Table
pattern is in 8-bit floating point format)? Example 13. What is the decimal value associated with 01111001(assume that the bit
Answer: 00.
Answer: Split the byte into the respective components,
8-bit Floating Point Notation
Step 1. Convert the excess-four exponent into its decimal equivalent.
The 8-bit floating point notation can be describe based on the byte shown below:
111 = 3, hence the exponent = 3.
7 a 6 a 5 a 4 a 3 a 2 a 1 a 0 a
Step 2. Since the exponent is positive, move the radix point three place to the
Where
right.
7 a
6 5 a (^) a (^4) a
The binary number
3
a (^3) a 2 (^) a (^1) a (^0)
The algorithm for converting from
(^) 8-bit floating point to decimal
(^) is detailed below:
Step 3. Convert the binary number to decimal, 100.1 = 4.
Step 4. Add the sign, hence 01111001 = 4.
decimal to 8-bit floating point
(^) is detailed below:
Set the sign bit (a
7
significant bit).
Convert the exponent into excess-4 notation (^6 5) a 4 a (^) to the exponent value.
(^3 2) a 1 0 a (^) a ).
(^0) a (^6) a (^5) a (^4) a (^3) a (^2) a (^1) a 0
2
Step 5. Fill in the exponentStep 4. Convert the exponent to excess-4, 2 = 110
(^0) a (^3) a (^2) a (^1) a 0
Hence 2 ¾ = 01101011
bit is 1.This allows us to gain an additional bit of precision in the representation. IEEE 754 Single Precision Floating Point Notation
Figure 2
. IEEE 32 bit floating point notation
The single precision
also defines a
(^) double precision
1.^ single precision standard. a. (^) set the sign bit to ‘1’
a. (^) Set the sign bit to ‘0’
bias 127 notation8 bit exponent in
23 bits to represent a 24 bit
The algorithm for converting from
) to 1 if the number is negative, 0 otherwise
Normalize the binary number (move the radix point to the left of the mostConvert the number into binary representation.
Select the 4 most significant bits and enter them into the fraction part (aSet a
There are some limitations of the 8-bit floating-point notation. Some of them are listed The precision is determined by the exponentThe maximum positive exponent is 3
Example 14: Convert 11/4 into 8-bit floating-point notation. Step 6. Fill in the fractionStep 3. Normalize 0010.11 = 0.1011 * 2Step 2. Convert the number into binary form,11/4 = 2 ¾ = 0010.11Step 1.
it is possible to use scientific notation instead and always implicitly assume that the firstGiven that the normalization procedure always has a 1 in the first significant bit position,
representation uses 32 bits as shown in Figure 2 above. The standard standard that uses 64 bits. We will only be discussing the
follows:The method for converting decimal numbers into the 754 standard representation is as Pad any remaining spaces with 0’s.Fill in the bits (except the most significant bit) into the mantissa from left to right.Fill in the 8 bits demarcated for the exponentright of the most significant bit).Convert the binary number into scientific notation (move the radix immediatelyConvert the decimal number into binary form.If the number is positiveIf the number is negative
is as follows:The exponent is computed as bias-127. The algorithm for computing the biased exponent Convert the decimal value into binarythe radix is moved to the left).Add 127 to the decimal value of the exponent (The exponent value is negative if
mantissa