CSC232 - Chp4 Computer Arithmetic
CSC232 - Chp4 Computer Arithmetic
1.8
4.1 Number Systems
1.10
4.1 Number Systems
1.12
4.1 Number Systems
1.14
4.1 Number Systems
• Sign-Magnitude
– The most significant bit (out of the n bits used to represent
the number) is used to represent the sign of the number
such that a “1’’ in the most significant bit position indicates
a negative number while a "0" in the most significant bit
position indicates a positive number.
– Remaining (n-1) bits are used to represent the magnitude.
– Although simple, the sign-magnitude representation is
complicated when performing arithmetic operations.
– In particular, the sign bit has to be dealt with separately from
the magnitude bits.
• Represent -18 and 25 and add them
1.15
4.1 Number Systems
• Radix Complement
– A positive number is represented the same way as in
the sign magnitude.
– However, a negative number is represented using the
b’s complement (for base b numbers).
• Examples
• Represent -18 and 25 and add them
• Represent -20 and 19 and add them
1.16
4.1 Number Systems
1.17
4.1 Number Systems
1.18
4.2 Integer Arithmetic
1.19
4.2 Integer Arithmetic
1.20
4.2 Integer Arithmetic
1.21
4.2 Integer Arithmetic
1.23
4.2 Integer Arithmetic
1.25
4.2 Integer Arithmetic
1.26
4.2 Integer Arithmetic
1.27
4.2 Integer Arithmetic
1.28
4.2 Integer Arithmetic
1.29
4.2 Integer Arithmetic
1.30
4.2 Integer Arithmetic
1.31
4.2 Integer Arithmetic
1.32
4.2 Integer Arithmetic
1.34
4.2 Integer Arithmetic
1.35
4.2 Integer Arithmetic
1.36
4.2 Integer Arithmetic
1.37
4.2 Integer Arithmetic
1.38
4.2 Integer Arithmetic
1.39
4.2 Integer Arithmetic
1.40
4.2 Integer Arithmetic
1.41
4.2 Integer Arithmetic
1.43
4.2 Integer Arithmetic
1.44
4.2 Integer Arithmetic
1.45
4.2 Integer Arithmetic
1.46
4.2 Integer Arithmetic
1.47
4.2 Integer Arithmetic
1.48
Game
Start at the bottom left square and move up, down, left or
right until you reach the finish. Add the numbers as you
go, can you make exactly 53?
4 9 7 7 4 Finish
8 9 4 5 7
6 6 4 9 9
7 8 8 8 6
Start 5 5 6 5 5
2.2
4.2 Integer Arithmetic
– Division:
• Among the four basic arithmetic operations, division is
considered the most complex and most time
consuming.
• An integer division operation takes two arguments, the
dividend X and the divisor D.
• It produces two outputs, the quotient Q and the
remainder R.
• The four quantities satisfy the relation X = Q× D + R
where R < D
1.50
4.2 Integer Arithmetic
1.51
4.2 Integer Arithmetic
1.53
4.2 Integer Arithmetic
1.55
4.2 Integer Arithmetic
1.56
4.2 Integer Arithmetic
1.57
4.2 Integer Arithmetic
1.58
4.2 Integer Arithmetic
1.59
4.2 Integer Arithmetic
1.62
4.2 Integer Arithmetic
1.63
4.2 Integer Arithmetic
1.64
4.3 Floating-Point Arithmetic
1.65
4.3 Floating-Point Arithmetic
1.66
4.3 Floating-Point Arithmetic
1.67
4.3 Floating-Point Arithmetic
1.68
4.3 Floating-Point Arithmetic
1.69
4.3 Floating-Point Arithmetic
1.70
4.3 Floating-Point Arithmetic
1.71
4.3 Floating-Point Arithmetic
1.73
4.3 Floating-Point Arithmetic
1.75
4.3 Floating-Point Arithmetic
1.76
4.4 Summary
1.77