Download presentation
Presentation is loading. Please wait.
1
Binary -ve and +ve numbers!
2
Objectives 3.1.2 Understand how computers represent and manipulate numbers [unsigned integers, signed integers (sign and magnitude, Two’s complement) real numbers] 3.1.3 Be able to convert between binary and denary whole numbers (0-255) and vice versa
3
Recap How do you convert positive denary numbers into positive binary numbers? 32 75 123 128 64 32 16 8 4 2 1
4
You have to learn 2 ways… There are a number of ways of representing negative numbers in binary. You need to know Sign and magnitude Two’s Compliment.
5
Sign and Magnitude When working with positive, and especially negative denary numbers you will see two things. - 12 Magnitude! Sign! Don’t forget the number 32 is actually +32 We use our intelligence to recognise there should be a + sign even if there isn’t!
6
sign and magnitude representation
In this approach, the problem of representing a number's sign can be to allocate one sign bit to represent the sign: Setting that bit (often the most significant bit) to 0 is for a positive number or positive zero, and setting it to 1 is for a negative number or negative zero.
7
Watch teacher demonstration
Are we wasting bits? Hence, in a byte with only seven bits (apart from the sign bit), The magnitude can range from (0) to (127). Thus numbers ranging from −12710 to can represented once the sign bit (the eighth bit) is added. Watch teacher demonstration
8
Another problem… A consequence of this representation is that there are two ways to represent zero, (0) and (−0).
9
Signed and Unsigned Unsigned 1100 Signed = a positive number 1 = a negative number = = = = -68 -1 62 -31
10
Two’s Complement To understand how this might work, imagine a brand new car with it’s odometer set to 0000 If you drive forward 1 mile it would be come 0001 What if you could reverse for 1 mile? It would say 9999
11
An Example 3 2 1 -1 -2 -3
12
Two's complement. The problems of multiple representations of 0 are circumvented by a system called two's complement. In two's complement, negative numbers are represented by the bit pattern which is one greater (in an unsigned sense) than the ones' complement of the positive value.
13
Converting a number. In two's-complement, there is only one zero, represented as Negating a number (whether negative or positive) is done by inverting all the bits and then adding 1 to that result.
14
Two’s Compliment -30 Step 1) Start off with the positive number Step 2) Invert the bits Step 3) You need to add one to the final number
15
Plenary What are the 2 methods for representing negative numbers?
What number is the following 10011? What is two’s complement? Why is two’s complement needed?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.