1

I am trying to understand and visualize the logic behind the base conversion method.

By "base" I mean how many numbers in a number system:

  1. The decimal number system we use every day has 10 digits {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} and so it is Base 10
  2. A binary digit can only be 0 or 1, so is Base 2
  3. A hexadecimal digit can be {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}, so is Base 16
  4. And we can use letters {A, B, C, ..., X, Y, Z}, and we get Base 26

Like in base 26 for AAA its 1* 26*26 + 1*26 + 1

Why formula is:- digit * ( base )^position index

Bill Dubuque
  • 272,048
  • 1
    That's the definition of a positional numbering system. I'm having trouble understanding what it is you are asking. Are you wondering how we know that every positive integer has a unique expression in such a system, for example? – saulspatz Mar 14 '21 at 18:11
  • You can set $\text{base}=10$ and then recall that the digit's positional value is $\text{digit}\times 10^\text{position index}$. (Remember "units, tens, hundreds, thousands...") What you have here is a simple generalization where $10$ is replaced with another number. –  Mar 14 '21 at 18:11
  • 1
    How many strings of length $n$ can be made? It's $d^n$ if the number of digits is $d$, they represent the numbers from $0$ to $d^n-1$, and $d^n$ will always be $1000\dots$ with $n$ leading zeroes. – Berci Mar 14 '21 at 18:13
  • I am having trouble visualizing and understanding why the formula works? Let's take an example of 777 = 7* 1010 + 710+7 . It is 7 column of 10*10 plus 7 the column of 10 set plus 7 @saulspatz – Sumeet Kumar Yadav Mar 14 '21 at 18:56
  • If you can visually help me to understand the intuation behind the formula? – Sumeet Kumar Yadav Mar 14 '21 at 18:57
  • What do you mean by "why the formula works"? The formula shows what number the string "$777$" represents in the decimal system. What does it mean for it to "work"? – saulspatz Mar 14 '21 at 18:58
  • 1
    Okay... take $384 = 3\times 100 + 8\times 10 + 4$. Why? Well, If we write down two symbols $mn$ and we have ten choices for $m$ and ten choices for $n$ that is $100$ pairs. We can have represent $100$ numbers (from $0$ to ... whatever number comes right before 100). And if we put a $1$ before all those choices we can get another hundred numbers. (for $100$ to whatever is before $200$) and by putting $2$ or $3$ we can get two more groups of $100$ numbers. So $3xx$ can represent $100$ different numbers in the four group ranging for $300$ to whetever comes before $400$. .. to be continued... – fleablood Mar 14 '21 at 19:15
  • 1
    ... so there are $100$ numbers that can be written as $3mn$ and these numbers can range from $300$ to just under $400$. Now we con list the first $10$ of these numbers as $300$ to $309$, and then next $10$ for $310$ to $319$. so the number $384$ would be after we did the eight groups of ten starting with $0,1,2,..7$ so that is $80$ number we can do before $380$. So $380$ to $389$ would be the numbers $300 +80 + 0$ to $300 + 80 + 9$. And $384$ would be the fifth number after the $0,1,2,3$ so it would be the $300 + 80 + 4$. – fleablood Mar 14 '21 at 19:21

2 Answers2

4

Because it works.

We need a way to express every possible whole numbers.

By having a base $b$ (assuming $b$ is a whole number larger than one) we can simply use the $b$ different digits to list the first $b$ whole numbers from $0$ to $(b-1)$.

(You might ask why $0$ to $b-1$ rather than $1$ to $b$. Technically it is arbitrary. But the indexing works out better if we start at "nothing")

That's the first group of $b$ numbers. We can do a second batch of $b$ numbers by putting a $1$ in front and relisting the $b$ digits after the $1$ for $1\color{blue}0$ to $1\color{blue}{(b-1)}$. This next group of number will go from $1\color{blue}0= b$ to $1\color{blue}{(b-1)} = b + (b-1) =2*b - 1$.

So those are the first $2b$ numbers from $0$ to $2b -1$.

We can do a third, fourth and fifth group of $b$ numbers (assuming our $b$ is that large by placing a $2,3,4$ befor and repeating the $b$ digits. We can do this for $b$ groups of $b$ from:

$\underbrace{\underbrace{0, 1,2 ,...,(b-1)}_{b} + \underbrace{10, 11,12 ,...,1(b-1)}_{b}+ \underbrace{20, 21,22 ,...,2(b-1)}_{b}+...... \underbrace{(b-1)0, (b-1)1,(b-1)2 ,...,(b-1)(b-1)}_{b}}_{b\text{ groups of }b\text{ numbers each}}$

This $b$ groups of $b$ numbers so this is $b^2$ numbers from $0$ to $b^2 -1$. The the number $ka$ would the int $k+1$th group which has the numbers from $k*b$ to $k*b + (b-1)$ and this is the $a+1$ number in the group and is the number $k*b + a$. (Okay, I admit it. The indexing from $0$ is confusing sometimes... but trust me... on the whole it is easier.

Now we have run out of two digit combos after $b^2$ numbers. (Which makes sense. We can have $b$ options for the first digit and $b$ for the second of $b^2$ total.)

But we can do another set of $b^2$ numbers but putting a $1$ before the two digits.

And if we put the $b$ digits before the two digits we can get $b$ groups of $b^2$ number making a total of $b^3$ numbers ranging from $0$ to $b^3-1$ but having $0...(b-1)$ being the numbers $0$ to $b-1$. $10$ to $(b-1)(b-1)$ being so that the number $an = a*b + n$ being the numbers from $b$ to $(b-1)*b + (b-1) = b^2-1$. And then numbers $100$ to $(b-1)(b-1)(b-1)$ where $amn$ would be the $a+1$th group of $b^2$ numbers which go from $ab^2$ to $a*b^2 + (b^2-1)$ and within that group it is the $m+1$th group of $b$ numbers that go from $a*b^2 + m*b$ to $a*b^2 + m*b + (b-1)$ and it is the $n+th$ number in the group so is $n$ more than $a*b^2 + m*b$ or is $a*b^2 + m*b + n$.

And we bootstrap up. We can get $(b-1)$ more groups of $b^3$ numbers but putting $1$ to $(b-1)$ before them to represent the first $b^4$ numbers with $4$ digits and so on.

It works.

And that's really all there is that can be said.

We do it because it will work.

cms
  • 127
fleablood
  • 124,253
  • Reminds me of how Archimedes of Syracuse designed a system of enumeration for very large numbers in order estimate the number of grains of sand that would fit in the universe. – cms Mar 16 '21 at 13:58
2

Say your number system has 10 digits. This means that you have numbers 0 through 9 to represent quantities 0 through 9. Once you run out of digits, but still want to represent a quantity numberically, it is conventional (at least in the West) to introduce a new digit to your number to the left of it.

What digit should that be? Well, if we have gone through digits 0-9 once, we can say that we have exhausted 1 of these quantities, so lets place a 1 and start the count from zero again, i.e. 10.

We can keep on going until we say that we have exhausted this quantity of 0-9 + 1 (one unit of ten), 9 + 1 times. Well, we've run out of digits again, so lets add a new digit to the left: 100. What does it mean, well, that we've gone through a unit of 10, 10 times. 10*10 = 100.

We can apply this reasoning for any base. 10 in hexadecimal means you've gone through 0-F one time. 100: you've gone through 10 (i.e. 16), 16 times. So, to figure out the value of 1000? You've gone through 16 * 16, 16 times, i.e. 16 * 16 * 16 = $16^3$

So, for any number base, to find out the value of a position index, you can say that you've gone up to the base at that position index a base number of times. Effectively, we can see that the forumla becomes $base^{position}$$ ^{index}$.

And for your forumla: $digit * base^{position}$$ ^{index}$. Well, say that you want to know what 20 represents in hexadecimal. Well, it simply means that you've gone from 0 to F not once, but twice. So that'll be 2 * 16 (as there are sixteen possible values from 0 to F).

And, we can of course apply this to other position indices. 200 in hex? Well, you've used up 16, 16 times, which is $16^2$, and you've done that twice, so $16^2 * 2$.

An extremely similar logic can be used when thinking about what values to apply after a floating point (we can't say decimal point as the decimal specifically refers to base 10). I am happy to elaborate on how we can find this too if need be.

  • 0 1 2 3 4 5 6 7 8 9 - 10 count , 10 11 12 .....99 - 90 count , how 100 = 1* 1010 +010+0 ? – Sumeet Kumar Yadav Mar 14 '21 at 18:45
  • Can you share some visual answer which is super easy to understand? – Sumeet Kumar Yadav Mar 14 '21 at 18:48
  • 1
    @Sumeet , if you're looking for a visual explanation, you might like this video: https://www.youtube.com/watch?v=5sS7w-CMHkU It uses a clock dial for number bases which might make things a little clearer for you. As for why 100 is 1* 1010 +010+0, would you be able to explain what part of my 3rd paragraph didn't quite make sense to you? – fruitless fruit juice Mar 14 '21 at 19:02