Procs
func as_integer_ratio(self: float; n = halfHigh(int)): (int, int) {. ...raises: [ValueError], tags: [], forbids: [].}
- see as_someinteger_ratio Source Edit
func as_someinteger_ratio[I: SomeInteger](self: float; n = halfHigh(I)): (I, I)
-
EXT. Calculates the best rational approximation of x, where the denominator is smaller than n (default is the largest possible I for maximal resolution),
The algorithm is from toRational of std/rationals, based on the theory of continued fractions. David Eppstein / UC Irvine / 8 Aug 1993 , but raises ValueError or OverflowDefect if x is NaN or Infinity.
Hint: due to lack of arbitrary length integers, its accuracy is not as high as Python'sSource Edit func checked_as_integer_ratio(self: float): (int, int) {....raises: [ValueError], tags: [], forbids: [].}
- EXT. like as_integer_ratio but raises OverflowDefect when cannot represent accurately. Source Edit
func float_fromhex(s: string): float {....raises: [ValueError, Exception], tags: [], forbids: [].}
- Source Edit
func is_integer(self: float): bool {....raises: [], tags: [], forbids: [].}
- Source Edit