diff options
author | Sébastien Dailly <sebastien@chimrod.com> | 2017-11-07 15:44:40 +0100 |
---|---|---|
committer | Sébastien Dailly <sebastien@chimrod.com> | 2017-11-08 14:05:56 +0100 |
commit | 6f6ff0e39eb6d771ef5336394079646ccdc18bd5 (patch) | |
tree | f06907f88972e8e87c5924de8eb225362a4a775b /scTypes.ml | |
parent | 50c16c8fc79d349f9db9d7975d1ae4e57050b648 (diff) |
Use Zarith instead of Num for computing numbers
Diffstat (limited to 'scTypes.ml')
-rwxr-xr-x | scTypes.ml | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -85,8 +85,8 @@ module DataFormat = struct end let default_value_for: type a. a dataFormat -> a = function - | Date -> DataType.Num.nan - | Number -> DataType.Num.nan + | Date -> DataType.Num.zero + | Number -> DataType.Num.zero | Bool -> false | String -> UTF8.empty @@ -106,7 +106,7 @@ module DataFormat = struct end module Type = struct - (* Required because Num.Big_int cannot be compared with Pervasives.(=) *) + let (=) : type a b. a types -> b types -> bool = fun t1 t2 -> match t1, t2 with | Num (_, n1), Num (_, n2) -> DataType.Num.eq n1 n2 @@ -131,15 +131,18 @@ module Type = struct | Str x -> UTF8.Buffer.add_string buffer x | Bool b -> UTF8.Printf.bprintf buffer "%B" b | Num (Number, n) -> - let n = DataType.Num.to_num n in - if Num.is_integer_num n then - UTF8.Buffer.add_string buffer @@ u(Num.string_of_num n) + if DataType.Num.is_integer n then + DataType.Num.to_int n + |> string_of_int + |> UTF8.from_utf8string + |> UTF8.Buffer.add_string buffer else - let to_b = UTF8.Format.formatter_of_buffer buffer in - ignore @@ UTF8.Format.fprintf to_b "%.2f" (Num.float_of_num n); + let f = DataType.Num.to_float n + and to_b = UTF8.Format.formatter_of_buffer buffer in + ignore @@ UTF8.Format.fprintf to_b "%.2f" f; Format.pp_print_flush to_b () | Num (Date, n) -> - let y, m, d = Date.date_from_julian_day (DataType.Num.to_num n) in + let y, m, d = DataType.Date.date_from_julian_day n in UTF8.Printf.bprintf buffer "%d/%d/%d" y m d end |