aboutsummaryrefslogtreecommitdiff
path: root/scTypes.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2017-11-07 15:44:40 +0100
committerSébastien Dailly <sebastien@chimrod.com>2017-11-08 14:05:56 +0100
commit6f6ff0e39eb6d771ef5336394079646ccdc18bd5 (patch)
treef06907f88972e8e87c5924de8eb225362a4a775b /scTypes.ml
parent50c16c8fc79d349f9db9d7975d1ae4e57050b648 (diff)
Use Zarith instead of Num for computing numbers
Diffstat (limited to 'scTypes.ml')
-rwxr-xr-xscTypes.ml21
1 files changed, 12 insertions, 9 deletions
diff --git a/scTypes.ml b/scTypes.ml
index a222f3b..075f25d 100755
--- a/scTypes.ml
+++ b/scTypes.ml
@@ -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