Computer Arithmetic Flashcards

1
Q

Decimal to Binary

A

Divide the number by 2 and remainder (0 or 1), and stop when the result is 0. The answer is the remainders read from bottom to top.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Binary to Decimal

A

Multiply the first non-zero bit by 2 and add the bit on its right.

Or from base 2
so an 8-bit number would look like
2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
0 0 0 0 0 1 0 0 = 2^2 = 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Hexadecimal

A

Base 16
Notation: 3B_16 = 0x3B = $3B

0000_2 - 1001_2
0_16 - 9_16

1010_2 - 1111_2
A_16. - F_16

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Binary Subtraction in relation to Addition

A

X - Y = X + (-Y)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Sign and Magnitude Representation

A

First bit represents the sign.

So,
00001101_2 = + 13_10
10001101_2 = - 13_10

To negate, just flip the sign bit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Two’s Complement Arithmetic

A

N represents -N using 2^n - N

Example:
N = 6_10 = 0110_2
-N = 2^4 - 6 = 10_10 = 1010_2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Decimal to Two’s Complement:

  1. If it’s positive
  2. If it’s negative (How to complement N)

Ex.
Convert 6 to binary and convert -6 to binary

A

Convert to binary normally if positive.
Invert sign of decimal. Now convert it to binary. Then takes two complement (Invert bits and add 1).

Ex:
1. 6 -> 0110

  1. -6 -> 6 -> 0110 -> 1001 -> 1010
    or as before, -6 -> 2^4 - 6 -> 10 -> 1010
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Arithmetic Overflow

A

Overflow occurs in two’s complement when addition of two positive number gives a negative result or when two negatives gives a positive.

How to detect it: Check the carry
   01100
\+ 01101 
\_\_\_\_\_\_
 1 1001
   1100
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Fixed Point Arithmetic

How to convert 0.25 to binary

A

Base 2 representation of decimals

2^3 2^2 2^1 2^0 . 2^-1 2^-2 2^-3 2^-4
0 0 0 0 . 0 1 0 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The normalisation of IEE FP

A

1010.101 x 2^e

1.010101 x 2^(e+3)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Representing Biased forms

Convert 3 to Bias 3
What’s the Bias for 8-bit

A

Bias: 2^(m-1) - 1

number - bias
3 - 3 = 0

Bias: 2^(7) - 1 = 127

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

IEEE 754 floating point format

A
X = (-1)^S x 2^(E-B) x 1.F
B = 127
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Decimal to IEEE FP

A

Convert to binary.
Normalise.
Add Bias B then convert the exponent to binary.

S Biased Exponent Fractional Mantissa
1 bit 8 bits 23 bits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

IEEE FP to Decimal

A

(-1)^S x (1+F) x 2^(E-B)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Floating Point Arithmetic

How to add

A

1.110100 x 2^5
+ 1.01001 x 2^3

change the exponent so they could be the same.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly