Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arbitrary base conversion #74

Open
stefnotch opened this issue Sep 12, 2021 · 2 comments
Open

Arbitrary base conversion #74

stefnotch opened this issue Sep 12, 2021 · 2 comments

Comments

@stefnotch
Copy link
Member

stefnotch commented Sep 12, 2021

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 stefnotch changed the title Decode as hexadecimal Arbitrary base conversion Sep 12, 2021
@stefnotch
Copy link
Member Author

stefnotch commented Oct 11, 2021

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:

  • Do the first part of the number base conversion as "usual", one can also cut to the chase by using something off the shelf such as this
  • Do the fractional part of the number base conversion as "usual" as well
  • Then, divide by (source base^number of places after the .) in the target base. Whee, division in a different base!

@stefnotch
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant