From dc32decd0586ca4c9b402351d2c4be646be0dca7 Mon Sep 17 00:00:00 2001 From: OCamlPro-Iguernlala Date: Wed, 29 Mar 2017 18:32:46 +0200 Subject: [PATCH] [bugfix in data_encoding] When writing a float (to binary format), MBytes.set_double should be used instead of MBytes.set_float (Float _ encodes doubles in the encoding, not singles) --- src/minutils/data_encoding.ml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/minutils/data_encoding.ml b/src/minutils/data_encoding.ml index fc7e5d71b..ed98dca1d 100644 --- a/src/minutils/data_encoding.ml +++ b/src/minutils/data_encoding.ml @@ -876,8 +876,10 @@ let rec length : type x. x t -> x -> int = fun e -> MBytes.set_int64 buf ofs v; ofs + Size.int64 + (** write a float64 (double) **) let float v buf ofs = - MBytes.set_float buf ofs v; + (*Here, float means float64, which is written using MBytes.set_double !!*) + MBytes.set_double buf ofs v; ofs + Size.float let fixed_kind_bytes length s buf ofs = @@ -1035,7 +1037,7 @@ let rec length : type x. x t -> x -> int = fun e -> (** read a float64 (double) **) let float buf ofs _len = - (* Here, float means float64, which is read using MBytes.get_double !! *) + (*Here, float means float64, which is read using MBytes.get_double !!*) ofs + Size.float, MBytes.get_double buf ofs let int_of_int32 i =