Close
Close full mode
logoMakeCode AP CSP

Base 62 and URL Shorteners

Base62

From Desmos

Did you know that there is such a thing as Base 62?!? That's right.

Video - Binary Numbers and Base Systems as Fast as Possible

Many URL shorteners use a Base 62 algorithm. Base 62 consists of 62 characters: 0-9, a-z lower case, plus A-Z upper case.

Just like binary, decimal, hexadecimal, each place value represents a power of 62.

62^0 = 1

62^1 = 62

62^2= 3844

6^23 = 238,328

Conversions work the same way:

  1. To convert a number < 62 to base 62, just look at the table.
  2. To convert a number > 61 to base 62:
    1. Create a table with columns of 1, 62, 62^2, 62^3, ...
    2. Find the largest power of 62 that divides into the given number, then convert.
decimalbase-62decimalbase-62
0031v
1132w
2233x
3334y
4435z
5536A
6637B
7738C
8839D
9940E
10a41F
11b42G
12c43H
13d44I
14e45J
15f46K
16g47L
17h48M
18i49N
19j50O
20k51P
21l52Q
22m53R
23n54S
24o55T
25p56U
26q57V

What is 100 in Base 62? 1C

  • 1 in the 62 place value
  • C (upper case)
  • 62 + 38 = 100

Convert 1000 to Base 62--> g8

g in the 62 place value =16, 16 x 62=992 + 8 in the 1s place valueConvert oc0 to decimal

(lower case o, lower case c, zero)-->93000

CHALLENGE: URL Shortener

A website has a URL that contains the decimal number 123456789089898. Convert this decimal number to base-62 and add the base-62 at the end of the bit.ly/_ in your web browser.

Solution:

123456789089898 is represented as : z3wBXxG2.

Students will visit Binary Challenge

πŸ“˜ Unit 6 - DAT β€” Previous
Denary to Hexadecimal via Binary Answer Key
Next β€” πŸ“˜ Unit 6 - DAT
Hexadecimal in MakeCode