Commit f95a8678 authored by Gábor Szalai's avatar Gábor Szalai
Browse files

Dropp the unusable digits in float str conversion (bug 566118)



Change-Id: I563dd0c7ddb32636f77e9e5900ca8702442da73a
Signed-off-by: Gábor Szalai's avatarGabor Szalai <gabor.szalai@ericsson.com>
parent 3d006566
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment