Converting Numbers from Base to Decimal

  • Context: High School 
  • Thread starter Thread starter Jkohn
  • Start date Start date
  • Tags Tags
    Base Numbers
Click For Summary

Discussion Overview

The discussion revolves around converting numbers from various bases to their decimal representations. Participants explore the concept of numeral systems, the limits of bases, and methods for conversion, including both theoretical and practical coding aspects.

Discussion Character

  • Exploratory
  • Technical explanation
  • Homework-related
  • Mathematical reasoning

Main Points Raised

  • Some participants express confusion about the terminology and seek resources for understanding base conversion.
  • There is a question about the limits of numeral bases, with one participant suggesting that bases can be as high as one million or more.
  • One participant proposes a method for converting numbers to binary using remainders, questioning if this method can be generalized to all bases.
  • Another participant describes a systematic approach for converting from base 10 to any base n, detailing steps involving powers of n and quotients.
  • It is noted that any positive integer can serve as a base, but bases larger than 10 require additional symbols for representation.
  • One participant shares their experience of writing a program that converts numbers across a wide range of bases, including unconventional ones.

Areas of Agreement / Disagreement

Participants generally agree that any positive integer can be a base, but there is no consensus on the practical limits of bases or the best methods for conversion. Multiple approaches and methods are discussed without resolution on which is superior.

Contextual Notes

Some methods discussed depend on specific assumptions about integer division and the representation of digits in bases larger than 10. The discussion includes various approaches without resolving the complexities involved in fractional bases or the conversion back to decimal.

Who May Find This Useful

This discussion may be useful for students learning about numeral systems, programmers interested in base conversion algorithms, and anyone exploring mathematical concepts related to bases and number representation.

Jkohn
Messages
31
Reaction score
0
Hey guys so I have to make a code for my class that you input a number..then you input the base..and it will print the decimal representation

I haven't seen this in math so I am a bit confused, just wanted to know what this was called so I can read up on a tutorial.

thanks!
 
Physics news on Phys.org
Jkohn said:
Hey guys so I have to make a code for my class that you input a number..then you input the base..and it will print the decimal representation

I haven't seen this in math so I am a bit confused, just wanted to know what this was called so I can read up on a tutorial.

thanks!

http://ultrastudio.org/en/MechengburakalkanApplet-1.7.zip

You have to run the Applet.
 
I just found video on khanacademy.. Relieved hehe..where I am a bit confused is: what is the limit on bases?? 1 2 4 8 16..is there more??
 
A base is just a way of counting. You could go up to base 1000000 if you want - or more. Any value will do.
In fact, there is a number called "e" which is an irrational value like pi, that is approximately 2.71828, that crops up very, very often in seemingly unrelated maths all throughout the field. The base of e is an extremely useful base, particularly when you reach exponential functions in calculus.
 
would it be logical to assume the following:
since the remainder of n/2 [until x^0]
can be used to get binary code
example
6 3 0
3 1 1
1 0 1

110=6

can I assume this for all bases?

ty!
 
Jkohn said:
would it be logical to assume the following:
since the remainder of n/2 [until x^0]
can be used to get binary code
example
6 3 0
3 1 1
1 0 1

110=6

can I assume this for all bases?

ty!
(assuming integer divide that truncates the number)

For 6 from base 10 to base 2:

6%2 = 0, 6/2 = 3
3%2 = 1, 3/2 = 1
1%2 = 1, 1/2 = 0

You stop at zero on the second and the list of numbers reversed is the binary: 110

Just like you did.

This works for all integer bases:

For 47 from base 10 to base 16 (using A-F for 10-15):

47%16 = 15, 47/16 = 2
2%16 = 2, 2/16 = 0

Hex: 2F

If you want a higher base, you have to have something to represent it, or you just put a comma between numbers like (2,15) instead of 2F or 0x2F

I guess you could call it decimal to other base conversion. To convert back is a little more complicated. You can do the same in that base (which can be confusing if you don't have a table), but it's easier to represent each numeral by the power representation of the base in that location and add it up to convert back, because you can do that in decimal.

Oh, like Kael42 said. Base can really be anything. You may want to stick to positive integer bases that are 2 are larger (2,3,4,5,...) until you get an idea how it works first. Well, you can do unary also, but then you'll have a lot of 1's across the screen.
 
Last edited:
Yet another approach to go from base 10 to base n:

Let x be written in base 10, to be written in base n:

i) Find the largest integer power a_1 of n that is smaller than x, i.e., n^a_1< x, but
n^(a_1+1)>x . Find the quotient q_1 of x by n^a1

ii) Find the largest integer power a_2 of n that is smaller than x-(n^a_1)
Again, find the quotient q_2 of x-q_1(n^a_1) by n^a2

iii) In the last step, you either get a multiple of n, then set q_k=0 , or you get
some number y smaller than n (this means x-(n^a_1-n^a_2-... n^a_(k-1) <n ), then set
q_k=y.

iv) Your number in base n is q_1q_2...q_k.

Example: 1670 in base 7:

i) Largest power of 7 smaller than 1670 is 343 . The quotient of 1670 by 343 is 4,
so q_1:=4

ii) Largest power of 7 smaller than (1670-4(343)=298) is, now 49, and the quotient
of 298 by 49 is 6 , so q_2:=6

iii) since q_2=4<7, declare q_4:= 4.

Then 1670 in base 7 is 4604 ; (4604)_7 = 4.7^0+ 0.7^1+ 6.7^2+ 4.7^3 =

4.1+0.7+ 6.49+ 4.343 = 4+0+ 294+ 1372.

So, basically, you recursively substract the multiple of the largest power of the base that is larger than zero , until you get something smaller than n.
 
Last edited:
Any positive integer can be a base (actually any positive number can but fractional bases are too complicated!). Also, if your base is larger than 10 you are going to need more symbols for "digits" greater than 9. Simplest is to use letters- A= 10, B= 11, etc.
 
I totally wrote a program like this with Qt, it converted to a ton of bases, from negasexagesimal to phinary, quater-imaginary, balanced ternary to sexigasmal..

Here: http://neuraloutlet.wordpress.com/projects/

You just need to have a good read through here: http://en.wikipedia.org/wiki/Numeral_system
 
Last edited by a moderator:

Similar threads

  • · Replies 7 ·
Replies
7
Views
3K
Replies
4
Views
2K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
5K
Replies
9
Views
2K