heptagon/examples/MC_memalloc/math.ept

12 lines
323 B
Plaintext

fun abs(a : float) returns (o : float)
let
o = if 0.0 <=. a then a else -. a;
tel
(* -- Returns 1.0 if input is greater than 0.0,
-- -1.0 if input is less than 0.0
-- and 0.0 if input is equal to 0.0 *)
fun sign(a : float) returns (o : float)
let
o = if a >. 0.0 then 1.0 else if 0.0 = a then 0.0 else -. 1.0;
tel