Data Representation and Number Systems Flashcards

1
Q

How to convert from decimal to base-R?

A

Whole numbers: divide by R until quotient hits 0. The remainder forms the base-R representation where the first remainder is the LSB and the last remainder is the MSB.
Fraction: multiply by R until product is either zero or a pattern is repeated. The carry over forms the base-R representation where the first carry over is the MSB and the last is the LSB.

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

Using a random number generator twice, convert the first number into the base representation of the second number

A

Check using https://www.rapidtables.com/convert/number/base-converter.html

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

How to do base conversion for normal cases?

A

Convert to decimal first then convert from decimal to target base.

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

What are some special cases for base conversions?

A
  1. Binary to octal: partition into groups of 3
  2. Octal to binary: split each number into a group of 3 numbers
  3. Binary to hexadecimal: partition into groups of 4
  4. Hexadecimal: split each number into a group of 4 numbers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the 3 common representations for negative binary numbers? And explain how to get each.

A
  1. Sign-and-magnitude, MSB acts as sign bit where 0 is positive and 1 is negative.
  2. 1s complement, invert all bits.
  3. 2s complement, invert all bits then add 1.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Formula to get (r - 1)’s complement, a.k.a radix diminished complement? Where n is the number of integer digits, m the number of fractional digits and N is the number to be represented

A

r^n - r^(-m) - N

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

Formula to get r’s complement, a.k.a radix complement? Where n is the number of integer digits and N is the number to be represented

A

r^n - N

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

How to perform addition and subtraction for 2s complement?

A

Addition: A + B, ignore the carry out of MSB and check for overflow. Overflow happens when ‘carry in’ and ‘carry out’ of MSB is different or sign is different from A and B.
Subtraction: A + (-B), get the 2s complement for B then add it to B.

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

How to perform addition and subtraction for 1s complement?

A

Addition: A + B, if there is a carry out of the MSB, add 1 to the result. Check for overflow which happens when the result is different sign with A and B
Subtraction: A + (-B), get the 1s complement for B then add it to A.

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

What is ‘Excess Representation’

A

A way to represent negative numbers using simple translation

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

What are the two ways to represent floats?

A

Fixed point representation (number of bits allocated for integer and fraction portion is fixed) and floating point representation which has 3 components: sign, exponent and mantissa.

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

Using a random number generator twice, convert the first number into binary fixed point representation with the second number as the size of integer portion. The size of the binary number is 16 bits.

A

Check using https://www.rfwireless-world.com/calculators/floating-vs-fixed-point-converter.html

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

Using a random number generator, convert this number into IEEE754 format.

A

Check using https://www.h-schmidt.net/FloatConverter/IEEE754.html

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