Merge pull request #1 from jepler/warn-bitlength

Improve the diagnostic when the user's circuitpython is too old
This commit is contained in:
Jeff Epler 2020-11-09 08:03:44 -06:00 committed by GitHub
commit b07a53bae3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -27,7 +27,7 @@ This library depends on:
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
Note that some CircuitPython core changes were needed to support udecimal.
These will be in upcoming release 6.0.0.alpha-4.
Please use CircuitPython 6.0.0-rc.1 or newer with udecimal.
The library also runs on desktop Python3, and should give numerically identical
results across all platorms.

View file

@ -160,6 +160,11 @@ except NameError:
if sys.implementation.name == "circuitpython":
if not hasattr(int, "bit_length"):
raise ImportError(
"jepler_udecimal requires int.bit_length. Use CircuitPython 6.0.0-rc.1 or newer."
)
def _as_integer_ratio(f):
m, e = _math.frexp(f)
m = round(m * (1 << 53))