X-Git-Url: https://svn.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/a186a0b2f3c996e9f17dd96e9f548e81f6447fe0..8abe2ee3f9b99450a1097204076770fc1c29b75a:/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;;