def as_integer_ratio
import bend-collections-laws-math@1.0.0.0/src/math/f64.bend as F64import Base
import bend-collections-laws-math@1.0.0.0/src/math/num.bend as N
1249# x = +-num / 2^den exactly, in lowest terms (Python's as_integer_ratio with
1250# the denominator's exponent); NaN is a domain error, infinities and integers
1251# of 2^64 or more overflow
1252def as_integer_ratio(+x: F64) -> Result<&2, &2, N.NumError, Ratio>:
1253 ar_cls(x, Nat.is_eq(exp_field(x), 2047n))