Base Conversion

Started by
2 comments, last by grhodes_at_work 19 years, 6 months ago
Say i want to convert bases, hex to dec or somthing like that. is there a way to easily convert the digits, or get the number of a certain digit?
Advertisement
Everything you'll ever need to know about bases...
Ra
Fast Answer: Divide and Modulus by the the Base.

Example: Base 10 to Base 3, the number 748.
(% refers to the Modulus, or Remainder of a number after division)

748 % 3 = 1
748 / 3 = 249
249 % 3 = 0
249 / 3 = 83
83 % 3 = 2
83 / 3 = 27
27 % 3 = 0
27 / 3 = 9
9 % 3 = 0
9 / 3 = 3
3 % 3 = 0
3 / 3 = 1
1 % 3 = 1
1 / 3 = 0

748 in Base 10 is 1000201 in Base 3.

This is just the iterative method, but it works.
william bubel
I'm closing the thread. Sounds like schoolwork/homework/NOT game-development related, with no justification provided. The Forum FAQ provides details on forum policy.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net

This topic is closed to new replies.

Advertisement