0% found this document useful (0 votes)
44 views5 pages

Binary Integer Representation Guide

Uploaded by

mohammed zayyad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views5 pages

Binary Integer Representation Guide

Uploaded by

mohammed zayyad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

INTRODUCTION

An integer is a whole number that can either be positive (greater than zero) or negative
(less than zero).
When representing these integers in binary, the base-2 number can be signed or
unsigned.
Signed binary numbers can be either positive or negative.
If the binary number doesn't use the signed method, it is considered to be unsigned,
meaning that the integer must be positive.
In this section, you will learn about how to to represent positive and negative integers.
Most and least significant bits

Signed integers can be positive or negative whole numbers. In denary, signed integers are
shown with a + or −. For example, −1, −2, 3, or 9. In denary, using a + for ‘positive’ is not
necessary because it is implied.
A binary representation of a signed integer has a most significant bit (MSB) and a least
significant bit (LSB).

Most and least significant bits

A signed integer representation uses the most significant bit to show if the integer is
positive or negative.
● 0 means that the number is positive
● 1 means that the number is negative
SIGN AND MAGNITUDE

One method of representing positive and negative integers in binary is called sign and
magnitude.
● Sign refers to the most significant bit, which represents if an integer is positive
(represented as a 0) or negative (represented as a 1)
● Magnitude is the size of the number being represented

Sign 4 2 1

1 1 0 1

In this example, the most significant bit is a 1, indicating that the number is negative.
The remaining bits represent the size of the number (magnitude):
4+1=5
Using 4-bit sign and magnitude representation, 11012 represents −510
When the most significant bit is used to represent the sign, the number of available bits
that can be used to represent an integer is reduced by 1 and this halves (rounded down)
the range of positive values that can be represented.
For example, when using 4 bits, the largest number you are able to store using an
unsigned binary number is 15, whereas using a signed binary number it is 7.

Unsigned and signed comparison

The same rules apply when using larger binary numbers. For example, 10110​represented
using 8-bit sign and magnitude representation would be:

sign 64 32 16 8 4 2 1

0 1 1 0 0 1 0 1
TWO'S COMPLEMENT

Another method for representing signed integers is two’s complement.


Two’s complement has a slight similarity to the sign and magnitude approach: the most
significant bit is used to indicate either a positive or negative number.
● 0 indicates a positive number
● 1 indicates a negative number
However, the representations are very different.
Here is a table that shows the place values of a 4-bit two’s complement integer.

−8 4 2 1

Using two's complement, the most significant bit has a negative value.
Representing a positive number using two's complement

To represent a positive number using 4-bit two's complement representation, a 0 is


placed as the most significant bit and then 0s and 1s are placed accordingly:

−8 4 2 1

0 1 1 1

In this example you can say that using 4-bit two’s complement representation,
01112​is equal to 710​

Representing a negative number using two's complement

Example 1

To represent a negative number using 4-bit two's complement representation, a 1 is


placed as the most significant bit and then 0s and 1s are placed accordingly:

−8 4 2 1

1 0 1 0
To work out the base-10 number this converts to, follow the same method that you used
before for your binary conversions:
−8 + 2 = −6
Therefore, you can say that using 4-bit two’s complement representation, 101010 is −610​

UNDERFLOW ERRORS

Underflow errors occur when a number is too small to be stored in the allocated number
of bits. A number is too small if it is too close to zero for it to be represented.
It is possible for binary numbers to represent real (floating-point) numbers. These are
numbers that include values after the decimal point (e.g. 1.5).

1.5 represented as a 8-bit binary number

You might also like