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 --- odf/odf.ml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'odf/odf.ml') diff --git a/odf/odf.ml b/odf/odf.ml index 8fa3411..ae120d9 100755 --- a/odf/odf.ml +++ b/odf/odf.ml @@ -31,11 +31,11 @@ let load_formula formula = let load_content content = begin function | "float" -> Expression.Basic ( ScTypes.number ( - DataType.Num.of_num (Tools.Num.of_float_string content) + DataType.Num.of_float (float_of_string content) )) | "date" -> Expression.Basic ( ScTypes.date ( - DataType.Num.of_num (Tools.Num.of_float_string content) + DataType.Num.of_float (float_of_string content) )) | _ -> Expression.Basic ( ScTypes.string ( @@ -170,13 +170,13 @@ let write_basic: type a. 'b list -> Xmlm.output -> a ScTypes.types -> unit = fun | ScTypes.Str s -> write_str attrs output (UTF8.to_utf8string s) | ScTypes.Bool b -> write_bool attrs output (string_of_bool b) | ScTypes.Num (data_type, d) -> - let n = DataType.Num.to_num d in begin match ScTypes.get_numeric_type data_type with | ScTypes.Number -> - let value = (string_of_float @@ Num.float_of_num n) in + let f = DataType.Num.to_float d in + let value = string_of_float f in write_num ((NS.value_attr, value)::attrs) output value | ScTypes.Date -> - let value = Date.to_string n in + let value = DataType.Date.to_string d in write_date ((NS.date_value_attr, value)::attrs) output value end end @@ -204,13 +204,14 @@ let rec print_expr : UTF8.Buffer.buffer -> ScTypes.expression -> unit = fun buff u(string_of_bool b) |> UTF8.Buffer.add_string buffer | ScTypes.Value (ScTypes.Num (data_type, d)) -> - let n = DataType.Num.to_num d in begin match ScTypes.get_numeric_type data_type with | ScTypes.Number -> - UTF8.Buffer.add_string buffer @@ u(string_of_float @@ Num.float_of_num n) + let f = DataType.Num.to_float d in + UTF8.Buffer.add_string buffer @@ u(string_of_float f) | ScTypes.Date -> - u(Date.to_string n) - |> UTF8.Buffer.add_string buffer + DataType.Date.to_string d + |> u + |> UTF8.Buffer.add_string buffer end | ScTypes.Ref r -> print_ref buffer r | ScTypes.Expression x -> -- cgit v1.2.3