From 6f6ff0e39eb6d771ef5336394079646ccdc18bd5 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Tue, 7 Nov 2017 15:44:40 +0100 Subject: Use Zarith instead of Num for computing numbers --- tools.ml | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) (limited to 'tools.ml') diff --git a/tools.ml b/tools.ml index f8f03cb..6dfe564 100755 --- a/tools.ml +++ b/tools.ml @@ -69,52 +69,6 @@ module String = struct end -module Num = struct - - include Num - - let of_float_string a = begin - try - let ipart_s,fpart_s = String.split a ~by:'.' in - let ipart = if ipart_s = "" then Num.Int 0 else Num.num_of_string ipart_s in - let fpart = - if fpart_s = "" then Num.Int 0 - else - let fpart = Num.num_of_string fpart_s in - let num10 = Num.num_of_int 10 in - let frac = Num.power_num num10 (Num.num_of_int (String.length fpart_s)) in - Num.div_num fpart frac - in - Num.add_num ipart fpart - with Not_found -> Num.num_of_string a - end - - let of_float f = begin - match classify_float f with - | FP_normal - | FP_subnormal -> - let x,e = frexp f in - let n,e = - Big_int.big_int_of_int64 (Int64.of_float (ldexp x 52)), - (e-52) - in - if e >= 0 then - Big_int (Big_int.shift_left_big_int n e) - else - Num.div_num - (Big_int n) - (Big_int Big_int.(shift_left_big_int unit_big_int ~-e)) - | FP_zero -> Num.num_of_int 0 - | FP_nan -> Num.div_num (Num.num_of_int 0) (Num.num_of_int 0) - | FP_infinite -> - if f >= 0. then - Num.div_num (Num.num_of_int 1) (Num.num_of_int 0) - else - Num.div_num (Num.num_of_int (-1)) (Num.num_of_int 0) - end - -end - module List = struct (** fold_left over only the first element *) -- cgit v1.2.3