aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/sys
diff options
context:
space:
mode:
authorSerge Aleynikov <[email protected]>2018-08-10 09:54:01 -0400
committerSverker Eriksson <[email protected]>2018-08-27 19:20:42 +0200
commit203ee6dcbd57c2fdbd9b9e09f0c42f7abf04dbd8 (patch)
tree9065a8b05b41a4daaf4e0ef1288857a458c6e151 /erts/emulator/sys
parentecea0a8b85e650ff717623dc6be2c18a8dbba971 (diff)
downloadotp-203ee6dcbd57c2fdbd9b9e09f0c42f7abf04dbd8.tar.gz
otp-203ee6dcbd57c2fdbd9b9e09f0c42f7abf04dbd8.tar.bz2
otp-203ee6dcbd57c2fdbd9b9e09f0c42f7abf04dbd8.zip
Fix bug in compact representation of float_to_list/2
Diffstat (limited to 'erts/emulator/sys')
-rw-r--r--erts/emulator/sys/common/erl_sys_common_misc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/erts/emulator/sys/common/erl_sys_common_misc.c b/erts/emulator/sys/common/erl_sys_common_misc.c
index 2541ab5d31..d34e1a9ec0 100644
--- a/erts/emulator/sys/common/erl_sys_common_misc.c
+++ b/erts/emulator/sys/common/erl_sys_common_misc.c
@@ -176,6 +176,7 @@ sys_double_to_chars_fast(double f, char *buffer, int buffer_size, int decimals,
double af;
Uint64 int_part, frac_part;
int neg;
+ int has_decimals = decimals != 0;
char *p = buffer;
if (decimals < 0)
@@ -257,7 +258,7 @@ sys_double_to_chars_fast(double f, char *buffer, int buffer_size, int decimals,
}
/* Delete trailing zeroes */
- if (compact)
+ if (compact && has_decimals)
p = find_first_trailing_zero(p);
*p = '\0';
return p - buffer;