Skip to content
Converts numbers in radix 2 to 36 with arbitrary precision
JavaScript CSS HTML
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
public style header Oct 24, 2019
src test negative input behavior Oct 25, 2019
.gitignore update README and .gitignore Oct 24, 2019
LICENSE initial commit Oct 16, 2019
README.md
package-lock.json testing Oct 25, 2019
package.json testing Oct 25, 2019

README.md

Radix Converter

This small tool is built using React. It converts numbers (integers and fractions) in radix 2 to 36 with arbitrary precision. This choice matches the specs of Javascript's numObj.toString([radix]) and parseInt(string, radix). Intuitively we have "a" mapped to decimal "10", "b" mapped to decimal "11", and all the way down "z" mapped to decimal "35". What makes this project cool is that we are not only handling Number type inputs that are limited to 64 bits, but also allowing arbitrarily big numbers including fractions.

The algorithm is in the src/utils/algo.js file. It's a straightforward algorithm if you use a specific number as an example and start from the function convert2all (keyword: Base-q expansion). Results are recomputed for all radixes every time the user changes the precision or the value in any radix. We can also put current results in a buffer and only recompute the added / deleted digits. I imagine there would be many ways to implement it, but all seem a bit messy to me. That's why I decided to let it be for now.

JSBI is used to ensure cross browser compatibility.

To Do

  • Testing the algorithm
  • Prevent numbers from overflowing
  • Some buggy behaviors for saving/storing caret
  • Display other radixes
  • Allow to set precision

If you have ideas to improve this project in any way, feel free to fork it😊

References

You can’t perform that action at this time.