Source  
Edit  
    
    
    Nim's Python-like math,  but raises no catchable exception, using errno to report math error. a.k.a. non will be raised (but not for Defects)
which allows fast code.
For Python-like error handler (exception-based), see Lib/math
Also this is not just a module that wraps Nim's std/math,
but also providing some extensions that Nim's std/math lacks, for example:
- JavaScript Backend and Compile-time (Nim VM) support for ldexp, frexp, cbrt, etc.
- JavaScript Backend support for erf, erfc, gamma, lgamma
- fsum, prod, etc.
And fix some non-C99 behavior on some systems, e.g. log(-ve) -> -Inf on Solaris
NOTE: Currently int is not acceptable when it comes to float about functions
    
  
  
    ../nimpatch/nansign, ../numTypes/ints/getter, math_impl/platformUtils, math_impl/errnoUtils, math_impl/ldexp, math_impl/cbrt, math_impl/expm1_log1p, math_impl/frexp, math_impl/nextafter_ulp, errno, math_impl/patch/fma, math_impl/vec_op, math_impl/isX, math_impl/patch/gamma, math_impl/patch/lgamma
  
 
  
  
    
  
  - func ceil(x: SomeFloat): int 
- 
    
    Hint:
unlike C/Nim's returning float, Python's returns int and raises errors for nans and infinities Source  
Edit
 
 
  
  - func comb(n, k: int): int {....raises: [], tags: [], forbids: [].}
- 
    
    Hint:
Python's math.comb does not accept negative value for n, k but Nim's std/math.binom allows, so this function allows too. For consistent behavior with Python, see  Lib/math.comb
 Source  
Edit
 
 
  
  - func floor(x: SomeFloat): int 
- 
    
    Hint:
unlike C/Nim's returning float, Python's returns int and raises errors for nans and infinities Source  
Edit
 
 
  
  - func gcd[I: SomeInteger](x, y, z: I; args: varargs[I]): I 
- 
    
    
    Source  
Edit  
  
 
 
  
  - func isqrt(n: Natural): int {....raises: [], tags: [], forbids: [].}
- 
    
    
Example: assert 2 == isqrt 5 Source  
Edit
 
  - func isqrt[T: SomeFloat](x: T): int {....raises: [].}
- 
    
    Hint:
assuming x > 0 (raise RangeDefect otherwise (if not danger build)) use math.isqrt if expecting raising ValueError Source  
Edit
 
 
  
  - func isqrtPositive(n: Positive): int {.inline, ...raises: [], tags: [], forbids: [].}
- 
    
    EXT: isqrt for Positive only, as we all know, in Python:- isqrt(0) == 0
- isqrt(-<positive int>) raises ValueError
 Source  
Edit
 
 
  
  - func lcm[I: SomeInteger](x, y, z: I; args: varargs[I]): I 
- 
    
    
    Source  
Edit  
  
 
 
  
  - func ldexp[F: SomeFloat](x: F; i: int): F {....raises: [].}
- 
    
    Hint:
only set errno Source  
Edit
 
  - func ldexp[F: SomeFloat](x: F; i: int; exc: var ref Exception): F {....raises: [].}
- 
    
    set exception to exc instead of raising it exc: - set to nil if no error
- set to suitable exc if some error occurs
 Source  
Edit
 
 
  
  - func math_is_error(x: SomeFloat; exc: var ref Exception): bool 
- 
    
    inner usage (used by Lib/math). Call this when errno != 0, and where x is the result libm returned.  This will usually set up an exception and return true, but may return false without setting up an exception. Source  
Edit
 
 
  
  - func modf[F: SomeFloat](x: F): tuple[intpart: F, floatpart: F] 
- 
    
    
    Source  
Edit  
  
 
 
  
  - func perm(n, k: Natural): int {....raises: [], tags: [], forbids: [].}
- 
    
    
    Source  
Edit  
  
 
  - func perm(n: int): int {....raises: [], tags: [], forbids: [].}
- 
    
    equal to perm(n,n), returns n!
    Source  
Edit  
  
 
 
  
  - func remainder[F: SomeFloat](x: F; y: F): F 
- 
    
    
    Source  
Edit  
  
 
 
  
  - func trunc(x: SomeFloat): int 
- 
    
    Hint:
unlike C/Nim's returning float, Python's returns int and raises errors for nans and infinities Source  
Edit
 
 
  
 
  
  
    expm1, log1p, cbrt, nextafter, nextafter, ulp, UNRELIABLE_FMA, fma, fma, c_fma, c_fma, sumprod, dist, dist, sumprod, OpenarrayOrNimIter, dist, isinf, isfinite, frexp, frexp