You are on page 1of 22

FOP PRESENTATION

Group 3
NEGATIVE NUMBERS IN BINARY

 Negative
number is represented into binary by the
method called Two’s complement
 The two's complement method is a way to represent
negative numbers in binary form. In this method, the
most significant bit (leftmost bit) is used to indicate the
sign of the number, where 0 represents a positive
number and 1 represents a negative number.
HOW TO REPRESENT A NEGATIVE NUMBER
USING TWO’S METHOD🤔??
 In a binary number system, the leftmost bit, also known as the
most significant bit (MSB), carries the sign information. If the
MSB is 0, the number is positive, while if it's 1, the number is
negative.
 To obtain the two's complement representation of a negative
number, we follow these steps:
1. Start with the positive binary representation of the number.
2. Invert (flip) all the bits, changing 0s to 1s and vice versa.
3. Add 1 to the resulting binary number.
EXAMPLE OF HOW TO CONVERT
NEGATIVE NUMBER INTO BINARY
 Let's illustrate this process with an example using an 8-bit
system. Suppose we want to represent -10 in binary:
1. Start with the positive binary representation of 10:
00001010.
2. Invert all the bits: 11110101.
3. Add 1 to the inverted number: 11110110.
 The resulting binary representation, 11110110, is the two's
complement representation of -10 in an 8-bit system.
NOTE THAT

 It'simportant to note that the range of representable


numbers in two's complement is determined by the
number of bits used. In an n-bit system, the range for
two's complement is typically from -2^(n-1) to 2^(n-1) -
1. In our 8-bit example, this range would be -128 to 127.
FOR MORE INFORMATION

 These are some example in order to have deep understanding about negative
number representation into binary.
 This picture will help you to understand two’s complement method.
Point/comma handling in binary

 In binary representation, there are no specific symbols for points or commas


as we have in decimal notation. Binary numbers only consist of 0s and 1s.
However, you can still represent fractional values in binary using techniques
like fixed-point or floating-point representation. These methods allow you to
handle numbers with fractional parts in binary format.
In binary computer system ,the point or
comma handling is typically done using fixed
point or floating representation
Fixed-point representation: In fixed-point representation, a specific number of
bits are allocated for the integer part and the fractional part of a binary number.
The position of the point or comma is implied based on the number of bits
reserved for the fractional part. For example, if 8 bits are allocated for a fixed-
point number with 4 bits for the integer part and 4 bits for the fractional part,
the point is assumed to be between the fourth and fifth bit.
Using floating representation

 Floating-point representation: Floating-point representation allows for a more


flexible handling of decimal numbers in binary format. It uses a combination
of sign, exponent, and mantissa to represent numbers. The point or comma is
not explicitly stored, but rather implied by the exponent value. The exponent
determines the position of the point or comma relative to the mantissa.
FIXED POINT REPRESENTATION
FLOATING POINT REPRESENTATION
RIGHT SHIFT BIT TO BIT IN NUMBERS

WHAT IS RIGHT SHIFT BIT TO BIT IN NUMBER


Right shift is a bitwise operator that shifts the bits of a number to the right. Each bit is
shifted to the right by a specified number of positions, and the leftmost bits are filled with
zeros.
for example: 8 >>3
• 0000 1000 —> 8 which is equal to 8/2^0
• Shift by 1 bit: 0000 0100 ----> 4 which is equal to 8/2^1
• Shift by 2 bits: 0000 0010 ----> 2 which is equal to 8/2^2
• Shift by 3 bits: 0000 0001 ----> 1 which is equal to 8/2^3
Steps to follow

1. Convert the Number to Binary:


2. Determine the Shift Amount: Determine the number of positions you want to
shift the bits to the right.
3. Right Shift Operation: Perform the right shift operation by moving each bit to
the right by the specified shift amount.
4. Repeat the Shift: If you need to shift further, repeat the right shift
operation for the desired number of times.
5. Interpret the Result: Once the right shift operation is complete, interpret
the resulting binary representation as the new number.
examples

 Consider the unsigned integer 23 (binary: 00010111) and perform a right shift
by 2 positions.
1. Binary Representation: 23 is already in binary form as 00010111.
2. Shift Amount: We want to shift by 2 positions.
3. Right Shift Operation:
 First Shift:
 Start with: 00010111
 Shift right by 1: 00001011
 Second Shift:
 Start with: 00001011
 Shift right by 1: 00000101

4. Interpret the Result: The final binary representation after two right shifts is
00000101, which is equal to the decimal number 5.
NOTES TO TAKE WHEN DEALING WITH
RIGHT SHIFT OF BINARY NUMBERS
 The number of positions to shift should be a non-negative integer
 The sign bit is preserved during the shift operation.
 The vacant bit positions on the left are filled with copies of the sign bit.
 The right shift operation is equivalent to dividing the number by 2 raised to the power
of the number of positions shifted.
Signed values range (characters &
integers short long)
 The signed values range for characters, integers (int), short integers (short), and long
integers (long) refers to the range of values that can be represented by these data types
while taking into account both positive and negative numbers.
Signed characters

1. Signed Characters (char):


1. Size: Typically 1 byte (8 bits)
2. Range: -128 to 127 (-2^7 to 2^7-1)
3. The range of signed characters represents integers from -128 to 127. The value 0 represents
zero, positive numbers range from 1 to 127, and negative numbers range from -1 to -128.
Signed Integers (int):

• Size: Typically 4 bytes (32 bits)


• Range: -2,147,483,648 to 2,147,483,647 (-2^31 to 2^31-1)
• The range of signed integers represents integers from -2,147,483,648 to 2,147,483,647.
The value 0 represents zero, positive numbers range from 1 to 2,147,483,647, and
negative numbers range from -1 to -2,147,483,648.
Signed short integer(short):

• Size: Typically 2 bytes (16 bits)


• Range: -32,768 to 32,767 (-2^15 to 2^15-1)
• The range of signed short integers represents integers from -32,768 to 32,767. The
value 0 represents zero, positive numbers range from 1 to 32,767, and negative
numbers range from -1 to -32,768.
Signed long integer(long):

• Size: Typically 4 bytes (32 bits) or 8 bytes (64 bits)


• Range: -2,147,483,648 to 2,147,483,647 (-2^31 to 2^31-1) for 32-bit long integers, or -
9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (-2^63 to 2^63-1) for 64-bit
long integers.
• The range of signed long integers represents integers from -2,147,483,648 to
2,147,483,647 for 32-bit long integers, and from -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807 for 64-bit long integers. The value 0 represents zero,
positive numbers range from 1 to the maximum value, and negative numbers range
from -1 to the minimum value.
GROUPE MEMBERS

 ISHIMWE Jolie Princesse


 IZABAYO Nadine
 KWIZERA Aimable
 KWIZERA Olivier
 MUGISHA Jemimah Gloire

You might also like