We provide a couple of additional elementary operations. The ulp
evaluable function is defined for integer, float and decimal. The
function returns a result of the same type as its argument. The
gcd and the evaluable function operation are currently only
defined for integers. The functions return a result of type
integer:
ulp: integer -> integer isqrt: integer -> integer ulp: float -> float sqrtrem: integer -> integer^2 ulp: decimal -> decimal iroot: integer^2 -> integer gcd: integer^2 -> integer rootrem: integer^2 -> integer^2
lcm: integer^2 -> integer divmod : number^2-> number^2
The ulp evaluable function makes use of the ulp() function of the Java Math library. The gcd evaluable function implements a binary gcd algorithm for 32-bit integers and otherwise delegates to the Java BigInteger gcd function implementation. The lcm evaluable function is bootstrapped from the gcd evaluable function. The isqrt evaluable function uses a logarithmic bisection method.
Examples:ulp(0) --> 1 isqrt(7) --> 2 ulp(0.0) --> 4.9E-324 sqrtrem(7) --> (2,3) ulp(0d0.00) --> 0d0.01 iroot(77,5) --> 2 gcd(36,24) --> 12 rootrem(77,5) --> (2, 45)
lcm(36,24) --> 72 divmod(12,-7) --> (-1,5)
The evaluable functions isqrt/1 and iroot/2 as well as the predicates sqrtrem/3 and rootrem/4 use the fast Hacker method of finding an integer root. The predicate divmod/4 returns both the quotient and remainder of a division. This is faster than invoking the ISO core standard evaluable functions (//)/2 and (rem)/2 separately.
The following elementary evaluable functions are provided: