Author Topic: Changing the Base of Numbers  (Read 6426 times)

0 Members and 1 Guest are viewing this topic.

Offline apcalc

  • The Game
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1393
  • Rating: +120/-2
  • VGhlIEdhbWUh (Base 64 :))
    • View Profile
Changing the Base of Numbers
« on: February 22, 2011, 05:25:15 pm »
I was wondering:  does anyone here know an extremely rapid/simple way to change the base of a number (by hand, not through a program :P)?  I have used methods I read about on the Internet, but none of them are very fast for me to do.  I always come across new ways to do things like this by hand, but I can't seem to find one for changing bases.  Does anyone know of a way to do this?  Thanks! :)


Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Changing the Base of Numbers
« Reply #1 on: February 22, 2011, 05:36:45 pm »
Oh, yes, that is rather easy/fun. All you do is use mod values and you don't even need to know what that means!
Basically you do X/A and you take the whole part and the remainder. A is your base. so if you do x=117 and A=10 you get 11 and 7. 7 is the last digit. So:

117→q
117/10: q=11 7=r
11/10 : q=1  1=r
1/10  : q=0  1=r

so your number is 117 in base 10 (go figure). Now for base 16:
117/16: q=7  5=r
7/16  : q=0  7=r

so in hex, 117 is 75h


Just remember that after 9 you start to use letters starting at A.

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: Changing the Base of Numbers
« Reply #2 on: February 22, 2011, 06:02:42 pm »
The way I like doing it is:
start with any number (1337_10)

Divide by the base you're calculating into (in this case, hex):
1337|16==>83r9
83|16==>5r3
5|16==>r5

Until you no longer have anything except for a remainder. Then read the remainders backwards.
539...easy?
« Last Edit: February 22, 2011, 06:03:36 pm by leafiness0 »
In-progress: Graviter (...)