You are on page 1of 23

Computer Architecture

Lecture 01 - Binary Representations

By – Ms. Piumi Gamage


Representation of numbers in Binary form

• Binary numbers can be positive or negative.


• So, binary numbers can be represented in signed and unsigned way.
• Number representation techniques like: Binary, Octal, Decimal and
Hexadecimal number representation techniques can represent numbers in
both signed and unsigned ways.
• Binary Number System is one the type of Number Representation techniques.
It is most popular and used in digital systems.
• Binary system is used for representing binary quantities which can be
represented by any device that has only two operating states or possible
conditions. For example, a switch has only two states: open or close.
Representation of
numbers in Binary form
Representing Positive
and Negative Numbers
Representation
of Binary
Numbers
Unsigned Numbers

• Unsigned numbers don’t have any sign, these can contain only magnitude of
the number
• Unsigned binary numbers are, by definition, positive numbers and thus do not
require an arithmetic sign
Signed Numbers

• Signed numbers contain sign flag, this representation distinguish positive and negative
numbers.
• This technique contains both sign bit and magnitude of a number.
• For example, in representation of negative decimal numbers, we need to put negative
symbol in front of given decimal number.
• There are two ways that we can represent a signed number
• Sign Magnitude form
• Complementary form
Sign Magnitude Form

• In this method there will be 2 parts in a binary number. That is Sign bit and actual binary
bits/magnitude bits.

0 111000

Sign Bit Actual binary Bit/ Magnitude Bit

• In this representation if the sign bit is “0”, the number is positive. If the sign bit is “1”, then the
number is negative.
Sign Magnitude Form

• Find the sign Magnitude of below numbers.

• +7 & -7
• +24 & -24
• +85 & -85
Complementary Form : 1`s Complement

• 1’s complement of a number is obtained by inverting/reversing each bit of given number


• If value of sign bit is 0, then number is positive, and you can directly represent it in simple
binary form.
• But if value of sign bit 1, then number is negative, and you have to take 1’s complement of
given binary number

0 111 + 7 -> 1`s complement


+7-> 0111
Sign Bit 1`s complement of actual binary Bit

1 000 -7-> 1`s complement


-7->1000
Sign Bit 1`s complement of actual binary Bit
Complementary Form : 2`s Complement

• Since, 2’s complement of a number is obtained by inverting each bit of given number plus 1 to
least significant bit (LSB).
• In other word to obtained 2`s compliment first we have to take `1`s complement of a number
and then add 1 to the LSB.
+ 7 -> 1`s complement
0 111 +7-> 0111
+7-> 2`s complement -> 0111
Sign Bit 2`s complement of actual binary Bit
-7-> 1`s complement
1 001 -7->1000
-7-> 1000 -> 2`s complement
Sign Bit 2`s complement of actual binary Bit + 1
1001
Complementary Form : Activity

• Find the 1`s complement of below numbers

• +3 & -3
• +41 & -41
• +12 & - 12
• Find the 2`s complement of below numbers

• +11 & -11


• +37 & - 37
• +56 & - 56
Representing Fractional
Numbers & Floating-Point
Numbers
Fractional Numbers in Binary

• Binary is a positional number system. It is also


a base number system.
• As we move a position (or digit) to the left, the
power we multiply the base (2 in binary) by
increases by 1 and as we move to the right, we
decrease by 1 (into negative numbers).
• For an example binary the number 101.101
translates as:
Floating point numbers in Binary

• We may do the same in binary and this forms the foundation of our floating point number.
• Here it is not a decimal point we are moving but a binary point and because it moves it is
referred to as floating.
• What we will look at below is what is referred to as the IEEE 754 Standard for representing
floating point numbers. The standard specifies the number of bits used for each section
(exponent, mantissa and sign) and the order in which they are represented.
• The standard specifies the following formats for floating point numbers:
• Single precision, which uses 32 bits
• Double precision, which uses 64 bits
Single precision (32 bit)

• 1 bit for the sign of the number. 0 means positive and 1 means negative.
• 8 bits for the exponent.
• 23 bits for the mantissa.
Decimal to Floating point Conversion

https://www.youtube.com/watch?v=8afbTaA-gOQ&t=20s
Decimal to Floating point Conversion
Floating point to Decimal Conversion

https://www.youtube.com/watch?v=LXF-wcoeT0o&t=75s
Activity

• Convert below Decimal number to floating point.


42.1

• Convert below floating-point number to decimal.


1 10000010 11010000000000000000000
Double precision (64 bit)

• Double precision, which uses 64 bits and has the following layout.
• 1 bit for the sign of the number. 0 means positive and 1 means negative.
• 11 bits for the exponent.
• 52 bits for the mantissa.

eg. 0 00011100010 0100001000000000000001110100000110000000000000000000


Questions?
Thank You

You might also like