We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6768677 commit 7ffc6beCopy full SHA for 7ffc6be
1 file changed
jepler_udecimal/__init__.py
@@ -158,6 +158,21 @@
158
except NameError:
159
NotImplemented = object()
160
161
+if sys.implementation.name == "circuitpython":
162
+
163
+ def as_integer_ratio(f):
164
+ m, e = _math.frexp(f)
165
+ m = round(m * (1 << 53))
166
+ e = e - 53
167
+ if e > 0:
168
+ return m * (1 << e), 1
169
+ else:
170
+ return m, (1 << (-e))
171
172
173
+else:
174
+ as_integer_ratio = float.as_integer_ratio
175
176
# Errors
177
178
@@ -722,7 +737,7 @@ def from_float(cls, f):
722
737
sign = 0
723
738
else:
724
739
sign = 1
725
- n, d = abs(f).as_integer_ratio()
740
+ n, d = as_integer_ratio(abs(f))
726
741
k = d.bit_length() - 1
727
742
coeff = str(n * 5 ** k)
728
743
0 commit comments