From f95a8678a07e28449aa040f98468f5869f371606 Mon Sep 17 00:00:00 2001
From: Gabor Szalai <gabor.szalai@ericsson.com>
Date: Tue, 18 Aug 2020 08:57:20 +0200
Subject: [PATCH] Dropp the unusable digits in float str conversion (bug
 566118)

Change-Id: I563dd0c7ddb32636f77e9e5900ca8702442da73a
Signed-off-by: Gabor Szalai <gabor.szalai@ericsson.com>
---
 compiler2/Real.cc | 4 ++--
 core/Float.cc     | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/compiler2/Real.cc b/compiler2/Real.cc
index 7ae01e689..e6eb1c1c9 100644
--- a/compiler2/Real.cc
+++ b/compiler2/Real.cc
@@ -48,7 +48,7 @@ namespace Common {
     double integral = floor(fraction);
     char   tmp[64];
 
-    sprintf(tmp, "%s%.16g%se%d",
+    sprintf(tmp, "%s%.15g%se%d",
             (sign == -1) ? "-" : "",
             fraction,
             (fraction == integral) ? ".0" : "",
@@ -68,7 +68,7 @@ namespace Common {
       Real exponent = floor(log10(rabs));
       Real mantissa = rabs * pow(10.0, -exponent);
 
-      char *tmp = mprintf("%s%.16g", r < 0.0 ? "-" : "", mantissa);
+      char *tmp = mprintf("%s%.15g", r < 0.0 ? "-" : "", mantissa);
       if (floor(mantissa) == mantissa) tmp = mputstr(tmp, ".0");
       if (exponent != 0.0) tmp = mputprintf(tmp, "e%d", (int)exponent);
       string ret_val(tmp);
diff --git a/core/Float.cc b/core/Float.cc
index ca33c37af..124035d55 100644
--- a/core/Float.cc
+++ b/core/Float.cc
@@ -79,7 +79,7 @@ static inline void log_float(double float_val)
       double exponent = floor(log10(rabs));
       double mantissa = rabs * pow(10.0, -exponent);
 
-      TTCN_Logger::log_event("%s%.16g", float_val < 0.0 ? "-" : "", mantissa);
+      TTCN_Logger::log_event("%s%.15g", float_val < 0.0 ? "-" : "", mantissa);
       if (floor(mantissa) == mantissa) TTCN_Logger::log_event( ".0");
       if (exponent != 0.0) TTCN_Logger::log_event("e%d", (int)exponent);
       
-- 
GitLab