Representing numbers Flashcards

1
Q

Converting base n to decimal

A

For each digit, work out d*b^p (digit, base, place)
The sum is the number in decimal

201.12 = 23^2 + 03^1 + 13^0 + 13^-1 + 2*3^2 = 18 + 1 + 1/3 + 2/9 = 19.55555

10010 = 12^4 + 02^3 + 02^2 + 12^1 + 0*2^0 = 8 + 2 = 10

DEAD = D16^3 + E16^2 + A16^1 + D16^0 = 134096 + 14256 + 1016 + 131 = 57005

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

Why do we use hexadecimal?

A

Reading and writing binary values is difficult for humans, more compact (can write numbers using fewer symbols), easy to convert to binary

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

Converting binary to hexadecimal

A

Separate it into nibbles and you can translate it easily

01011000 = 0101 1000 = 5 8 = 58

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

Converting decimal to binary

A

Repeatedly divide by 2 and write down the remainders right to left until you get to 1/2 = 0 + 1

69/2 = 34 + 1
34/2 = 17 + 0
17/2 = 8 + 1
8/2 = 4 + 0
4/2 = 2 + 0
2/2 = 1 + 0
1/2 = 0 + 1

Read this “backwards” to get 1000101

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

Converting decimal fractions into binary

A

Multiply the number by 2 and if the result is equal to/greater than 1, subtract 1 and write down a “1”, otherwise write down “0”. Repeat until you reach 1.

0.40625 * 2 = 0.8125, 0
0.8125 * 2 = 1.625, 1
0.625 * 2 = 1.25, 1
0.25 * 2 = 0.5, 0
0.5 * 2 = 1.0, 1

0.40625 = 0.01101

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

Converting base n to base m

A

<Compiete>
</Compiete>

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

Multiplying binary numbers

A

<Compiete>
</Compiete>

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

Signed Magnitude Representation for representing negative numbers

A

Add a bit at the beginning representing the sign (0 = positive, 1 = negative)
0000 0110 = 6
1000 0110 = -6
Has two zero values, makes binary arithmetic difficult

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

Ones complement for representing negative numbers

A

To make a number negative, flip all its bits
(e.g. 0100 1001 = 73, 1011 0110 = -73)
The first bit still represents the sign, still has two ways of writing zero

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

Twos complement for representing negative numbers

A

Make a number negative by flipping its bits and adding 1
(e.g. 0100 1001 = 73, 1011 0110 + 1 = 1011 0111 = -73)
The first bit still represents the sign
Makes binary arithmetic simple, only one representation for zero

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

Bias notation for representing negative numbers

A

Stores a number N as an unsigned value N+B, where B is the bias (half the unsigned range)
e.g. -65 is represented as -65 + 127 = 62 (0011 1110)
-8 is represented as 119 (0111 0111)
2 is represented as 129 (1000 0001)

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

Structure of a single precision 32-bit floating point number

A

+/- M * 2^e

1-bit sign, 8-bit exponent e, 23-bit mantissa M

The exponent is in the range -126 to 127, and is stored with a bias, meaning the number which gets converted into binary is actually between 1 and 254

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

Floating numbers with special meanings

A

Normal numbers have exponents between 1 and 254 (e = -126 to 127)
exponent 0 and mantissa 0 means 0
exponent 0 and mantissa not 0 means subnormal number
exponent 255 with mantissa 0 means +/- infinity
exponent field 255 with mantissa not 0 means NaN

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

How is the mantissa stored?

A

Scaled so that it starts with 1.xxxxxx
The leading 1 is then removed, meaning we only need to store 23 bits.

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

Converting a number (-12.375) into floating point

A

12.375 = 1100.011
Keep moving the decimal place until the number becomes 1.xxxxx
1100.011 = 1.100011 * 2^3
Sign bit is 1 (negative)
Get rid of the .1
Mantissa part is 1000110000000…
Exponent part is 3+127 = 130 = 1000 0010
11000001010001100000000000000000

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