tuwien2020 / tgi-pages

Open tools for the TGI course at the TU Vienna
https://tuwien2020.github.io/tgi-pages/#/
The Unlicense
12 stars 5 forks source link

Arbitrary base conversion #74

Open stefnotch opened 2 years ago

stefnotch commented 2 years ago

It might be useful to have a page which lets us convert numbers from any base to any other base. And unlike other calculators out there, it should do so with arbitrary precision.

stefnotch commented 2 years ago

In the spirit of this math stackexchange answer, here is how to probably deal with fractional numbers.

(0.1235)_6 = 1 * 1/6 + 2*1/(6^2) + 3*1/(6^3) + 5*(1/6^4)
x := 6^4 
           = (1*6*6*6)/x + (2*6*6)/x + (3*6)/x + 5/x
           = (1*6*6*6 + 2*6*6 + 3*6 + 5)/x

tl;dr:

stefnotch commented 2 years ago

We got a proper "arbitrary base arithmetic" class on the base-converter branch. So, time to turn this into reality