From 5cfbc7bab507ea81a71553ed42a966eba61b5248 Mon Sep 17 00:00:00 2001 From: penguindark <57967770+penguindark@users.noreply.github.com> Date: Sat, 21 Dec 2019 23:38:02 +0100 Subject: [PATCH] float: bug fix on +zero --- vlib/strconv/atof.v | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/vlib/strconv/atof.v b/vlib/strconv/atof.v index 2a194b8aaf..d6c9ed6525 100644 --- a/vlib/strconv/atof.v +++ b/vlib/strconv/atof.v @@ -489,16 +489,18 @@ fn converter(pn mut PrepNumber) u64 { } s1 = s1 & check_round_mask s0 = u32(0) + + // recheck normalization + if s2 & (mask28<> 8) // C.printf("mantissa after rounding : %08x%08x%08x binexp: %d \n", s2,s1,s0,binexp) // C.printf("Tmp result: %016x\n",tmp) @@ -516,6 +518,8 @@ fn converter(pn mut PrepNumber) u64 { else if binexp < 1 { if pn.negative { result = DOUBLE_MINUS_ZERO + } else { + result = DOUBLE_PLUS_ZERO } } else if s2 != 0 {