X-Git-Url: https://scm.cri.mines-paristech.fr/git/Faustine.git/blobdiff_plain/a186a0b2f3c996e9f17dd96e9f548e81f6447fe0..c21be74684e409aaf08937e776c6cedce35b8fc0:/interpretor/aux.ml?ds=sidebyside 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;;