COMP 211: Lecture 6 - Information Encoding, Number Systems, and Integer Representation (and Character Encoding)c

studied byStudied by 0 people
0.0(0)
Get a hint
Hint

What do humans understand?

1 / 77

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

78 Terms

1

What do humans understand?

Numbers and strings (i.e characters)

New cards
2

What are examples of what humans understand?

100 or the matrix

New cards
3

What do machines understand?

Binary numbers

New cards
4

Do machines understand human language?

No. We have to convert human language into binary representation

New cards
5

What is encoding?

To convert information into a different form.

New cards
6

What is a character example of binary encoding?

‘a’ encoded as binary 01100001_2 number

New cards
7

What is the representation for transforming characters to binary?

ASCII representation

New cards
8

What is a number example of binary encoding?

25_10 encoded as 00011001_2 number

New cards
9

What is the representation for transforming numbers to binary?

Base-2 representation

New cards
10

How many digits do base-10 numbers have?

10; 0-9

New cards
11

What does it mean for a number to be base-10?

Each digit is multiplied by a power of 10

New cards
12

What is the formula for getting to base-10?

v is base-10 value, d is decimal digit, and i is digit position, increasing right to left, starting from 0

New cards
13
  • How do we get 17543_10?

  • How do we get 173_10?

  • How do we get 1025_10?

  • How do we get 2001_10?

Answer

New cards
14

What are base-2 numbers?

Binary numbers

New cards
15

How many digits to base-2 numbers have?

2 binary digits; 0 and 1

New cards
16

What does it mean for a number to be base-2?

Each digit multiplied by power of 2

New cards
17

What is the formula for getting to base-2?

v is base 10 value, b is binary digit, and i is digit position

<p><span>v is base 10 value, b is binary digit, and i is digit position</span></p>
New cards
18

What is the range of binary numbers?

0 - (2^N-1)

N = Number of bits

New cards
19
  • How do we get 011111010000_

  • How do we convert 73_10 to binary?

  • How do we convert 181_10 to binary?

  • How do we convert 213_10 to binary?

  • 2000_10

  • 01001001

  • 10110101

  • 11010101

New cards
20

What are some Base-2 Terminology?

LSB, MSB

New cards
21

What is LSB?

Least significant bit

New cards
22

What is MSB?

Most significant bit

New cards
23

What is considered the least significant bit? What is considered the most significant bit?

The LSB is going to be the lowest power of two, and the MSB is the highest power of 2

New cards
24

What is the goal of a Decimal to Binary Algorithm?

We can apply a more algorithmic approach to converting a base-10 decimal number to binary; inverse problem

New cards
25

What is the Decimal to Binary Algorithm?

knowt flashcard image
New cards
26

Where does the Decimal to Binary Algorithm Apply?

To any other number bases

New cards
27

How do we use the Decimal to Binary Algorithm on other number bases?

for base-n, replace divide by 2 with divide by n

New cards
28
  • Convert 18_10 to binary (base-2)

10010

New cards
29

What are Base-16 numbers also called?

Hexadecimal numbers

New cards
30

How many digits are in hexadecimals?

16 hex digits; 0-9 and A-F

New cards
31

What is a hex digit also called?

Hexit

New cards
32

What is a hexdigit?

A group of 4 binary bits

<p>A group of 4 binary bits</p>
New cards
33

What is each hexit multiplied by?

A power of 16

New cards
34

WHat is the formula for hexits?

v is base-10 value, d is hexit, and i is digit position (increasing right to left, starting at 0)

<p>v is base-10 value, d is hexit, and i is digit position (increasing right to left, starting at 0)</p>
New cards
35
  • 0×7d0

  • Convert 73_10 to Hexadecimal

  • Convert 01101100_2 to Hexadecimal

  • Convert 0xA9 to Binary

0111 1101 0000

0049

6C

1010 1001

New cards
36

What is ASCII?

A standard format with 7 bits encoded to 128 characters

New cards
37

How many characters total in ASCII?

2^7'

New cards
38
  • ‘A’ in base_10, base_2, and base_16

  • ‘0’ in base_10, base_2, and base_16

  • ‘\0’ in base_10, base_2, and base_1

65; 1000001; 0×41

48; 0110000; 0×30

0; 0000000; 0×00

New cards
39

What character has a 0 value?

The null terminator

New cards
40

Why is the null terminator value important?

Because it’s the only character with 0 value, it allows us to null terminate strings (recognizes the end of a string)

New cards
41
  • Convert ‘brent’ to Binary

<p></p>
New cards
42

What is fixed-length encoding?

When all symbols have same number of bits

New cards
43

What is an example of fixed-length encoding?

ASCII; each character always has 7 bits

New cards
44

When is fixed-length encoding used?

When all symbols have equal probability

New cards
45

What is variable-length encoding?

When symbols can use different numbers of bits

New cards
46

What is an example of variable-length encoding?

UNICODE 8 and 16

New cards
47

When is variable-length encoding used?

When some symbols are more likely than others; for example, compression

New cards
48

Variable-length Example

  • Suppose X and Y are twice as likely as W and Z

  • Encoding possibility: X and Y are 1 bit, W and Z are 2 bits

  • X and Y would use less bits, while W and Z require more bits

  • Main concept is commonly occurring symbols are encoded with few bits; the idea behind compression

New cards
49

How do we determine the number of bits for fixed-length representation?

  • Number of symbols = to 2^ number of bits

  • if we had 2 symbols, one bit is needed

  • If we had 4 symbols, 2 bits are needed

  • If we have 2^n symbols, then n bits are needed

    • We take the ceiling of log_2(M) to find number of bits for M symbol==

<ul><li><p>Number of symbols = to 2^ number of bits</p></li><li><p>if we had 2 symbols, one bit is needed</p></li><li><p>If we had 4 symbols, 2 bits are needed</p></li><li><p>If we have 2^n symbols, then n bits are needed</p><ul><li><p>We take the ceiling of log_2(M) to find number of bits for M symbol==</p></li></ul></li></ul>
New cards
50
  • If we had the digits {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, how many bits are need?

  • If we had the 84 english characters (A-Z (26), a-z (26), 0-9 (10), punctuation (8), math (9), financial (5)), how many bits are need?

log[10] = 3.22 → 4

log[84] = 1.92 → 2

New cards
51

What is MSB used for? How?

Used to encode the sign. If MSB = 0_2, then it is a positive binary number. If MSB = 1_2, then it is a negative binary number.

<p>Used to encode the sign. If MSB = 0_2, then it is a positive  binary number. If MSB = 1_2, then it is a negative binary number.</p>
New cards
52

What is the range for Signed Magnitude Representation?

-(2^(N-1) - 1) to (2^(N-1) - 1)
N = # of bits

New cards
53

What is the range represented in?

Base-10

New cards
54

If N = 8 bits, what is the minimum base-10 number that can be represented in signed magnitude? What is the maximum base-10 number

-127 - 127

New cards
55
  1. What is -49 in SMR

  2. What is +49 in SMR

  3. What is +86 in SMR

  4. What is -86 in SMR

10110001

00110001

01010110

11010110

New cards
56

Why is Signed Magnitude Good?

Easy to negate and compute the absolute value.

New cards
57

What is one reason why Signed Magnitude is bad?

Adding and subtracting can become complicated because we would need to implement a first hardware circuit to the add, and a second hard ware circuit to subtract.

New cards
58

What is the second reason why Signed Magnitude is bad?

2 different ways to represent 0. If all the bits are 0 and the MSB is 1, then the number is a -0. If the MSB is 0, then it is +0. Being able to represent 0 in 2 different ways is not ideal because it can complicate hardware design

New cards
59

What is signed representation like in practice?

It is not frequently used for integer numbers, but used in floating point numbers.

New cards
60

What is another signed representation?

2’s Complement Representation.

New cards
61

How is the sign encoded in 2’s Complement?

MSB is used, so 1 = negative sign, and 0 = positive sign. Conversion from base-10 to base-2 is slightly different from standard MSB Signed magnitude.

<p>MSB is used, so 1 = negative sign, and 0 = positive sign. Conversion from base-10 to base-2 is slightly different from standard MSB Signed magnitude.</p>
New cards
62
<p>2’s Complement examples</p>

2’s Complement examples

-42

42

New cards
63

What is another process other than the formula to convert base-10 to base-2 in 2’s Complement?

A two step negating a number and algorithmic approach.

New cards
64

Explain the 2’s complement second approach.

  1. Complement every bit (1_2 → 0_2, 0_2 → 1_2)

  2. Add 1_2 using binary math (see supplement reading assignment)

New cards
65
<p>2’s Complement Example</p>

2’s Complement Example

Answer

<p>Answer </p>
New cards
66
  1. +86 to 2’s Complement

  2. -86 to 2’s Complement

<p></p>
New cards
67

What is 2’s complement’s range?

(-2^(N-1)) to (2^(N-1) - 1)

New cards
68

If N = 8, what is the range in 2‘s complement?

Answer

<p>Answer</p>
New cards
69

What will happen if you apply 2’s complement to a negative number?

You will get a positive number.

New cards
70
<p>Apply 2’s Complement to this negative number.</p>

Apply 2’s Complement to this negative number.

knowt flashcard image
New cards
71

What is another thing we can do in 2’s complement? Why?

Addition, no subtraction. Because we use the MSB to determine whether the number is negative or not, we could do the number + a negative number to perform subtraction.

New cards
72

What is a good thing about representing integers in 2’s Complement?

There is only one 0, no positive or negative 0.

New cards
73

Prove the claim about the 0 in 2’s complement.

Answer

<p>Answer</p>
New cards
74

Signed Magnitude vs 2’s Complement

knowt flashcard image
New cards
75
<p>Sign Extension Example.</p>

Sign Extension Example.

We would pad the MSBs with 0s to make 8. We don’t change the value of the number.

New cards
76

What do we do if we wanted sign extension with a negative binary nmber?

We would need to use 2’s complement, signed magnitude does not work.

<p>We would need to use 2’s complement, signed magnitude does not work.</p>
New cards
77

What is the bad things about 2’s complement?

More complex to negate and compute the absolute value.

New cards
78

What are all the good things about 2’s complement?

2’s complement fixes the issues with signed magnitude. It uses only the add operation, only has one 0, and can use sign extension. Overall, it simplifies hardware design.

New cards

Explore top notes

note Note
studied byStudied by 51 people
... ago
5.0(1)
note Note
studied byStudied by 9 people
... ago
5.0(1)
note Note
studied byStudied by 14 people
... ago
5.0(1)
note Note
studied byStudied by 4 people
... ago
5.0(1)
note Note
studied byStudied by 59 people
... ago
5.0(3)
note Note
studied byStudied by 7 people
... ago
4.0(1)
note Note
studied byStudied by 123508 people
... ago
4.8(561)

Explore top flashcards

flashcards Flashcard (85)
studied byStudied by 4 people
... ago
5.0(2)
flashcards Flashcard (37)
studied byStudied by 17 people
... ago
5.0(1)
flashcards Flashcard (40)
studied byStudied by 11 people
... ago
5.0(1)
flashcards Flashcard (56)
studied byStudied by 548 people
... ago
4.8(5)
flashcards Flashcard (169)
studied byStudied by 1 person
... ago
5.0(1)
flashcards Flashcard (24)
studied byStudied by 4 people
... ago
5.0(2)
flashcards Flashcard (118)
studied byStudied by 52 people
... ago
5.0(1)
flashcards Flashcard (21)
studied byStudied by 2 people
... ago
5.0(1)
robot