3 ms·
A Python package for floating-point binary fractions. Do math in base 2
- Jonny-exe 5y agoA python package for manipulating binary strings with infinite precision. It comes with tones of helper functions such as: add, shift, fill, to_exponential...
- Someone 5y agoI don’t understand why this was implemented the way it is (keeping the binary representation using strings with one bit/character). I would think using fractions (https://docs.python.org/3/library/fractions.html https://docs.python.org/3/library/fractions.html) and doing conversion from/to binary on read/write would be faster unless you do very little math and thus spend most of your time reading and writing these numbers. As a bonus (IMO) those also give you exact representations of ⅓, ⅕, etc, so calculations involving them can have more accurate results by doing the lossy conversion only when printing the binary representation. What do I overlook?