Docsity

Logarithms and Their Relationships: Understanding Base 2 and Base 10, Slides of Programming Languages

Partial preview of the text

Download Logarithms and Their Relationships: Understanding Base 2 and Base 10 and more Slides Programming Languages in PDF only on Docsity!

Logarithms

Strings of bits

 There is only one possible zero-length sequence of bits

 There are two possible “sequences” of a single bit: 0 , 1

 There are four sequences of two bits: 00 01 , 10 11

 There are eight sequences of three bits: 000 001, 010 011,

 Each time you add a bit, you double the number of possible

sequences

 Add 0 to the end of each existing sequence, and do the same for 1

 “Taking the logarithm” is the inverse of exponentiation

0

1

2

3

= 8, etc.

 log

2

1 = 0 log

2

2 = 1 log

2

4 = 2 log

2

8 = 3, etc.

Relationships

 Logarithms of the same number to different bases differ by a

constant factor

 log 2 (2) = 1.000 log 10 (2) = 0.301 log 2 (2)/log 10

 log 2 (3) = 1.585 log 10 (3) = 0.477 log 2 (3)/log 10

 log 2 (4) = 2.000 log 10 (4) = 0.602 log 2 (4)/log 10

 log 2 (5) = 2.322 log 10 (5) = 0.699 log 2 (5)/log 10

 log 2 (6) = 2.585 log 10 (6) = 0.778 log 2 (6)/log 10

 log 2 (7) = 2.807 log 10 (7) = 0.845 log 2 (7)/log 10

 log 2 (8) = 3.000 log 10 (8) = 0.903 log 2 (8)/log 10

 log 2 (9) = 3.170 log 10 (9) = 0.954 log 2 (9)/log 10

 log 2 (10)= 3.322 log 10 (10) = 1.000 log 2 (10)/log 10

Review

 Logarithms are exponents

 if b

x

= a, then log

b

a = x

 if 10

3

= 1000, then log

10

 if 2

8

= 256, then log

2

 If we start with x=1 and multipy x by 2 eight times,

we get 256

 If we start with x=256 and divide x by 2 eight

times, we get 1

 log

2

is how many times we halve a number to get 1

 log

2

is the number of bits required to represent a

number in binary (fractions are rounded up)

 In computer science we usually use log to mean log

2