Download presentation
Presentation is loading. Please wait.
1
Storing Negative Integers
Negative numbers There are two distinct methods used for storing negative numbers Two’s complement (invert a positive number and add 1 to the end) Sign and Magnitude
2
Storing Negative Integers
1 method is Sign/Magnitude 75 -75 MSB 64 32 16 8 4 2 1 +/- 128 1 1 1 1 1 1 is a Negative, 0 is a Positive
3
Sign and Magnitude 64 32 16 8 4 2 1 +/- 1 1 1 1 Sign
This method has some limitations 2 types of data in the same value (MSB is a sign) Makes calculations difficult by losing 1 bit 127 maximum number 64 32 16 8 4 2 1 +/- 1 1 1 1 Sign Value or Magnitude
4
Representation of Data as Bit Patterns – Sign and Magnitude
The following represents -35 using sign and magnitude sign 64 32 16 8 4 2 1
5
Representation of Data as Bit Patterns – Sign and Magnitude
Using the example of trying to store +35 in 8 bits Hint- Don’t forget first number should be your SIGN sign 64 32 16 8 4 2 1
6
Representation of Data as Bit Patterns – Sign and Magnitude
Using the example of trying to store +35 in 8 bits sign 64 32 16 8 4 2 1
7
Sign and Magnitude – Task
Represent the following numbers, in 8 binary bits, using Two’s complement notation -23 -101 -20 Represent the following numbers, in 8 binary bits, using sign and magnitude notation 17 -99 -67
8
Answers – two’s complement
128 64 32 16 8 4 2 1 -23
9
Answers – two’s complement
128 64 32 16 8 4 2 1 -23
10
Answers – two’s complement
128 64 32 16 8 4 2 1 -23 -101
11
Answers – two’s complement
128 64 32 16 8 4 2 1 -23 -101
12
Answers – two’s complement
128 64 32 16 8 4 2 1 -23 -101 -20
13
Answers – two’s complement
128 64 32 16 8 4 2 1 -23 -101 -20
14
Answers – sign and magnitude
64 32 16 8 4 2 1 17
15
Answers – sign and magnitude
64 32 16 8 4 2 1 17 -99
16
Answers – sign and magnitude
64 32 16 8 4 2 1 17 -99
17
Answers – sign and magnitude
64 32 16 8 4 2 1 17 -99 -67
18
Answers – sign and magnitude
64 32 16 8 4 2 1 17 -99 -67
19
Representation of Data as Bit Patterns – ASCII code
What is ASCII code? Why is it used? Why is it required? Find the meaning of Truncating & Rounding Find the meaning of Mantissa & Exponent
20
Representing characters
There are two main coding systems that provide conversions of keyboard characters into binary: ASCII UNICODE
21
ASCII ASCII stands for the American Standard Code for Information Interchange. It has been adopted as the industry standard way of representing English language keyboard characters as binary codes. Every keyboard character is given a corresponding binary code. ASCII uses an 7-bit code to provide 128 characters. ASCII is a code for representing English characters as numbers, with each letter assigned a number from 0 to 127. For example, the ASCII code for uppercase M is 77. Most computers use ASCII codes to represent text, which makes it possible to transfer data from one computer to another
22
ASCII Code If you wanted to represent the word JOHN in ASCII, it would look like this: The word JOHN would take 4 bytes of memory to store. J O H N 1 Byte
23
UNICODE UNICODE is the new standard to emerge that is replacing ASCII.
Uses 16 bits per character It is designed to cover more of the characters that are found in languages across the world. It has become important due to the increased use of the Internet, as more data is being passed around globally.
24
Truncation and Rounding
If the result of a calculation is too big to fit into the designated register, the number needs to be shortened This can be done in one of two ways Truncation Rounding Research Task
25
Truncation This method simply involves removing all the digits after the required amount of space has been used E.g with only 6 digits being available to store the number The last 3 9s are just removed, their value having no significance
26
Rounding This method involves trying to find the best number to represent the one required E.g – with only 6 digits being available to store the number The last digit is rounded ‘up’ due to the values that are unable to be stored
27
Truncation and Rounding
It should be clear that both of these methods of storing numbers will lead to inaccurate results when calculations are performed upon them
28
Overflow and Underflow
Overflow, this occurs when an answer has been produced which is too big for the system to store This is most likely to happen when the multiplication of numbers takes place The actual point at which the overflow occurs depends on how many bits the register is able to handle Underflow, this occurs when the number produced is smaller than what the system can handle These numbers tend then to be held as zero Error messages can / are produced when either of the above occur
29
Floating Point Form So far we can store and manipulate integers that can be either positive or negative These numbers though are restrictive in the range of numbers they can store To store much larger numbers and those with decimal points, Floating Point Form is used This holds the number as two separate parts Mantissa Exponent
30
Floating Point Form E.g. 1 – using a decimal example 1.634 x 1020 1.634 is the mantissa 20 is the exponent The number above means that the decimal point needs to be moved 20 places to the right Giving:- 163,400,000,000,000,000,000
31
Floating Point Form E.g. 2 – using a decimal example 1.634 x 10-20 1.634 is the mantissa -20 is the exponent The number above means that the decimal point needs to be moved 20 places to the left Giving:-
32
Question Using the Mantissa and Exponent, what is one likely problem?
33
Floating Point Representation
34
Fixed Point Notation The decimal point does not move – hence fixed point Here is a 16-bit fixed point representation The decimal point is fixed between the 12th and 13th bits in this example
35
1 Fixed Point Notation For Example….
1 The value of this number would be….
36
Fixed Point Notation For Example…. 2048 1024 512 256 128 64 32 16 8 4 2 1 1/8 1/16 The value of this number would be….
37
Fixed Point Notation For Example…. 2048 1024 512 256 128 64 32 16 8 4 2 1 1/8 1/16 = ½ + ¼ = 15 ¾
38
Fixed Point Notation Advantage. Stores the number accurately Disadvantage. Can not represent a wide range of numbers. E.g r This disadvantage can be solved by introducing a floating point All real numbers in computer systems are stored using floating point notation
39
2.56 x 104 = 2 5 6 0 0 .0 Floating Point Notation
In standard notation we represent numbers like this.. The 4 here determines the position of the decimal point 2.56 x 104 =
40
Floating Point Notation
In floating point notation it’s the same principle just in base 2.. x 24 = 16 8 4 2 1 1/8 = 14.25
41
0.1110010 x 24 Floating Point Notation
So, if we store numbers in floating point.. We have to store this THE MANTISSA x 24 And this. THE EXPONENT
42
1 Imagine a 12 bit number with 8 bit mantissa and 4 bit exponent
1 Mantissa – holds the precision Exponent – holds the power of 2 the mantissa should be multiplied by
43
4 2 1 Imagine a 12 bit number with 8 bit mantissa and 4 bit exponent
The decimal point always starts Between the first two digits Calculate the exponent. In this case 3 so.. x 23 Multiplying by 23 will have the effect of floating the decimal point 3 places to the right so….
44
4 2 1 Imagine a 12 bit number with 8 bit mantissa and 4 bit exponent 1
1 Multiplying by 23 will have the effect of floating the decimal point 3 places to the right so….
45
4 2 1 Imagine a 12 bit number with 8 bit mantissa and 4 bit exponent 1
1 2 Multiplying by 23 will have the effect of floating the decimal point 3 places to the right so….
46
4 2 1 Imagine a 12 bit number with 8 bit mantissa and 4 bit exponent 1
1 2 3 Multiplying by 23 will have the effect of floating the decimal point 3 places to the right so….
47
Imagine a 12 bit number with 8 bit mantissa and 4 bit exponent
So this would give us.. 4 2 1 … Remember - get rid of the exponent when you have worked out where the decimal point goes! 7.25
48
So 2-3 -8 4 2 1 Positive Mantissa and Negative exponent
Both the mantissa and exponent are represented in twos complement. Imagine this 12 bit number with 8 bit mantissa and 4 bit exponent -8 4 2 1 The decimal point always starts Between the first two digits Calculate the exponent. – = -3 So 2-3 Multiplying by 2-3 means floating the decimal point 3 places left so..
49
Both the mantissa and exponent are represented in twos complement.
Imagine this 12 bit number with 8 bit mantissa and 4 bit exponent … . -8 4 2 1 Pad with 0s -positive = 1/16 + 1/128 = REMEMBER if the mantissa is negative then the number will Be negative.
50
8 4 2 1 Negative mantissa and Positive exponent
Both the mantissa and exponent are represented in twos complement. Imagine this 12 bit number with 8 bit mantissa and 4 bit exponent 8 4 2 1 = -4.5 3 -8 4 2 1 1/2
51
Floating Point Notation
Advantage. Being able to move the decimal point allows us to represent a much greater range of numbers Disadvantage. Some loss of precision because some bits have to be used to hold the exponent (where the decimal point should be)
52
TRY THESE – They get harder!!
(use 8 bit mantissa and 4 bit exponent) 5.75 0.75 0.125 (1/8TH) -8.5 (- 1/16TH)
53
Floating Point Representation
54
Floating Point – Things to remember
The decimal point always starts between the first two digits of the mantissa. Positive mantissa = positive number Negative mantissa = negative number Positive exponent = number is going to be 1 or bigger (bigger than -1 if negative) Negative exponent = number is going to be smaller than 0.5. (-0.5 if negative)
55
What type of error maybe generated?
Multiplying two very large numbers Overflow Dividing a large number by a very small number Overflow Dividing a very small number by a very large number Underflow
56
Floating Point Form While it should be clear that the range of numbers available using floating point representation is vast, there are disadvantages to using this representation of numbers The is likely to be a loss of accuracy A decision has to be made how many bits are to be used for the mantissa (the precision) and how many for the exponent (the range)
57
Floating Point Form E.g. using a 16 bit register
10 bits for the mantissa and 6 bits for the exponent Gives good precision but quite a limited range 6 bits for the mantissa and 10 bits for the exponent Gives little precision but a far greater range Processing time is also increased when using floating point, due to the value needing to be calculated when required
58
Task Jan Describe what are meant by the terms overflow and underflow in connection with storing numbers in a computer. [2] One advantage of storing numbers in floating point form in a computer is that it can be used to store very large (positive or negative) numbers. State one other advantage of using floating point form rather than integer form. State one advantage of storing numbers in integer form. [2]
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.