Converting Numbers from Base to Decimal

In summary, the conversation discussed the concept of converting numbers from one base to another. The original poster mentioned needing to make a code for a class that would input a number and a base, and then print the decimal representation of that number. They also mentioned not being familiar with this concept in math and asking for the name of it. The concept was explained as a way of counting and it was mentioned that there is no limit to the bases that can be used. The conversation also touched on the use of irrational bases, such as the base of "e", and the potential for using different symbols for digits greater than 9. Various examples were given to demonstrate the process of converting numbers from one base to another, and the conversation ended with a
  • #1
Jkohn
31
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
  • #2
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.
 
  • #3
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??
 
  • #4
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.
 
  • #5
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!
 
  • #6
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:
  • #7
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:
  • #8
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.
 
  • #9
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:

What is the process for converting numbers from another base to decimal?

To convert a number from another base to decimal, you must first identify the base of the original number. Then, multiply each digit in the number by the corresponding power of the base (starting from 0), and add all the values together. The resulting sum is the decimal equivalent of the original number.

What is the purpose of converting numbers from another base to decimal?

Converting numbers from another base to decimal allows us to easily compare and manipulate numbers from different number systems. It also allows us to perform mathematical operations on these numbers using the familiar decimal system.

What are some commonly used number systems besides decimal?

Some commonly used number systems besides decimal are binary (base 2), octal (base 8), and hexadecimal (base 16). Binary is commonly used in computer systems, while octal and hexadecimal are used in programming and digital design.

How do you convert a number from decimal to another base?

To convert a number from decimal to another base, you must divide the decimal number by the new base repeatedly until the quotient is 0. The remainders of each division, in reverse order, make up the new number in the desired base.

Are there any shortcuts or tricks for converting between bases?

There are a few tricks and patterns that can make converting between bases easier. For example, in base 2, each digit represents a power of 2, so you can use the powers of 2 to quickly convert from binary to decimal. In base 16, you can use the letters A-F to represent the numbers 10-15.

Similar threads

Replies
4
Views
932
  • Linear and Abstract Algebra
Replies
9
Views
577
  • Computing and Technology
Replies
4
Views
769
  • Introductory Physics Homework Help
Replies
6
Views
568
  • Engineering and Comp Sci Homework Help
Replies
2
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
887
  • Programming and Computer Science
Replies
29
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
9
Views
956
  • Programming and Computer Science
Replies
17
Views
1K
  • Linear and Abstract Algebra
Replies
6
Views
1K
Back
Top