X-Git-Url: https://scm.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/a186a0b2f3c996e9f17dd96e9f548e81f6447fe0..992d59159547267e1491fcd1c5123765b4c452b8:/interpretor/aux.ml diff --git a/interpretor/aux.ml b/interpretor/aux.ml index a33e722..7c21a61 100644 --- a/interpretor/aux.ml +++ b/interpretor/aux.ml @@ -27,3 +27,10 @@ let rint : float -> float = fun f -> if (f -. (floor f)) >= 0.5 then ceil f else floor f;; + +let remainder_float : float -> float -> float = + fun f1 -> fun f2 -> + let r = mod_float f1 f2 in + if (abs_float r) > ((abs_float f2) /. 2.) then + (if r *. f2 > 0. then (r -. f2) else (r +. f2)) + else r;;