Chapter 3 Arithmetic for Computers

仉昂熙
2023-12-01

3.12 Exercises

3.1

// unsigned 16-bit hex
5ED4 - 07A4 = 5730

3.2

// signed 16-bit hex
5ED4 - 07A4 = 5730

3.3

// convert 5ED4 into a binary number
5ED4 = 0101 1110 1101 0100

3.4

// unsigned 12-bit oct
4365 - 3412 = 0753

3.5

// signed 12-bit oct
4365 - 3412 = 4753

3.6

// unsigned 8-bit dec
185 = 1011 1001
122 = 0111 1010
185 - 122 = 0011 1111 = 63
neither

3.7

// signed 8-bit dec
185 = 1011 1001
122 = 0111 1010
185 + 122 = 0011 0011
overflow

3.8

// signed 8-bit dec
185 = 1011 1001
122 = 0111 1010
185 - 122 = 1100 0001
underflow

3.9

// signed 8-bit dec num stored in two's complement
151 = 1001 0111
214 = 1101 1000
151 + 214 = 1001 0111 + 1101 1000 = 0110 1111 = 111

3.10

// signed 8-bit dec num stored in two's complement
151 = 1001 0111
214 = 1101 1000
151 - 214 = 1001 0111 - 1101 1000 = 1011 1111 = 191

3.11

// unsigned 8-bit 
151 = 1001 0111
214 = 1101 1000
151 + 214 = 1001 0111 + 1101 1000 = 0110 1111 = 111

3.12

IterationStepMultiplierMultiplicandProduct
0Initial values001 010110 010000 000
11a:1=>Prod = Prod + Mcand001 010110 010110 010
2:shift left Multiplicand001 010100 100110 010
3:shift right Multiplier000 101100 100110 010
21a:1=>Prod = Prod + Mcand000 101100 100010 100
2:shift left Multiplicand000 101001 000010 100
3:shift right Multiplier000 010001 000010 100
31a:1=>Prod = Prod + Mcand000 010001 000011 100
2:shift left Multiplicand000 010010 000011 100
3:shift right Multiplier000 001010 000011 100
41a:1=>Prod = Prod + Mcand000 001010 000101 100
2:shift left Multiplicand000 001100 000101 100
3:shift right Multiplier000 000100 000101 100
51a:1=>Prod = Prod + Mcand000 000100 000001 100
2:shift left Multiplicand000 000000 000001 100
3:shift right Multiplier000 000000 000001 100
61a:1=>Prod = Prod + Mcand000 000000 000001 100
2:shift left Multiplicand000 000000 000001 100
3:shift right Multiplier000 000000 000001 100

3.13

Method as above

3.14

// if this is being done in hardware
eight time units
// if this is being done in software
twelve time units

3.15

time = log2(31) * 4 = 20

3.16

time = log2(8) * 4 = 12

3.17

0 X 33 X 0 X 55 = 0 X (32 + 1) X 0 X (64 - 9)
= 0 X (2 X 2 X 2 X 2 X 2 + 1) X 0 X (2 X 2 X 2 X 2 X 2 X 2 - (2 X 2 X 2 + 1))

3.18

I am lazy

3.19

I am lazy

3.20

// if it is a two's complement 
3072
// if it is an unsigned 
3072

3.21

I don't know

3.22

// if it is a floating point
s = 0
E = 65
F = 1.0
value = 1.0 x 2 ^ 65

3.23

// single precision format
63.25 = 111111.01 = 1.1111101 x 2 ^ 5
s = 0
exp = 5 + 127 = 1000 0100B
0 10000100 11111010000000000000000

3.24

// double precision format
63.25 = 111111.01 = 1.1111101 x 2 ^ 5
s = 0
exp = 5 + 1023 = 10000000100B
0 10000000100 1111101000000000000000000000000000000000000000000

后面的题不写了…

 类似资料:

相关阅读

相关文章

相关问答