Jump to content
  • Advertisement
Sign in to follow this  
Axiverse

Base Conversion

This topic is 5468 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites

This topic is 5468 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!