Description
Python library designed for parsing, validating, and converting numbers across different numerical bases (ranging from base 2 to base 36). It handles both integer and fractional components, supports signed numbers (+ or -), and parses inputs using custom character mappings.
How it works
When a BaseNumber object is created, the number - regardless of its original base - is first converted to base 10. The integer and fractional parts are calculated separately, as they require different approaches.
Once the object has been successfully created, it is ready to be converted to any other base. This is handled by the convert_to method. De facto, this method consists of two sub-methods that calculate the integer and fractional parts separately. It does not rely on complex algorithms, but rather on the most basic and convenient method described in this article on base conversions.
About tests and more
A fair number of tests were conducted to verify the package's operation. Yet, come to think of it, there aren't actually that many. It’s just that running them required me to manually recalculate—and convert between—hundreds upon hundreds of numbers with various bases. In short, I’m now confident I can convert any number from any base to any other base in my head. That’s the level of mastery I’ve reached.
As for additional features, I’ll decide on those as I write utilities using this library. For now, it includes only the core functionality needed for my online base converter tool.
Reviews
(0)