From 0da4dbe2322eb3b6224df35ce3e9fc83f104762b Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Thu, 14 Apr 2016 19:09:36 -0700 Subject: all: remove unnecessary type conversions cmd and runtime were handled separately, and I'm intentionally skipped syscall. This is the rest of the standard library. CL generated mechanically with github.com/mdempsky/unconvert. Change-Id: I9e0eff886974dedc37adb93f602064b83e469122 Reviewed-on: https://go-review.googlesource.com/22104 Reviewed-by: Brad Fitzpatrick Run-TryBot: Matthew Dempsky TryBot-Result: Gobot Gobot --- src/strconv/extfloat.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/strconv') diff --git a/src/strconv/extfloat.go b/src/strconv/extfloat.go index 019b4eebdc..7033e96c39 100644 --- a/src/strconv/extfloat.go +++ b/src/strconv/extfloat.go @@ -311,9 +311,9 @@ func (f *extFloat) AssignDecimal(mantissa uint64, exp10 int, neg bool, trunc boo var extrabits uint if f.exp <= denormalExp { // f.mant * 2^f.exp is smaller than 2^(flt.bias+1). - extrabits = uint(63 - flt.mantbits + 1 + uint(denormalExp-f.exp)) + extrabits = 63 - flt.mantbits + 1 + uint(denormalExp-f.exp) } else { - extrabits = uint(63 - flt.mantbits) + extrabits = 63 - flt.mantbits } halfway := uint64(1) << (extrabits - 1) -- cgit v1.3 From 5e74d4095241655ce6bf6e5d32eeaeef353b614f Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 19 Apr 2016 14:42:15 -0700 Subject: strconv: fix ParseFloat for special forms of zero values Fixes #15364. Change-Id: Id2a349896064c7c9e00e36c55162068bf18162b2 Reviewed-on: https://go-review.googlesource.com/22272 Reviewed-by: Brad Fitzpatrick --- src/strconv/atof.go | 4 +++- src/strconv/atof_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) (limited to 'src/strconv') diff --git a/src/strconv/atof.go b/src/strconv/atof.go index ce76252340..ada85e9fed 100644 --- a/src/strconv/atof.go +++ b/src/strconv/atof.go @@ -244,7 +244,9 @@ func readFloat(s string) (mantissa uint64, exp int, neg, trunc, ok bool) { return } - exp = dp - ndMant + if mantissa != 0 { + exp = dp - ndMant + } ok = true return diff --git a/src/strconv/atof_test.go b/src/strconv/atof_test.go index 9f70cc1fd7..0a89c3e0bf 100644 --- a/src/strconv/atof_test.go +++ b/src/strconv/atof_test.go @@ -42,6 +42,30 @@ var atoftests = []atofTest{ {"1e-20", "1e-20", nil}, {"625e-3", "0.625", nil}, + // zeros + {"0", "0", nil}, + {"0e0", "0", nil}, + {"-0e0", "-0", nil}, + {"+0e0", "0", nil}, + {"0e-0", "0", nil}, + {"-0e-0", "-0", nil}, + {"+0e-0", "0", nil}, + {"0e+0", "0", nil}, + {"-0e+0", "-0", nil}, + {"+0e+0", "0", nil}, + {"0e+01234567890123456789", "0", nil}, + {"0.00e-01234567890123456789", "0", nil}, + {"-0e+01234567890123456789", "-0", nil}, + {"-0.00e-01234567890123456789", "-0", nil}, + {"0e291", "0", nil}, // issue 15364 + {"0e292", "0", nil}, // issue 15364 + {"0e347", "0", nil}, // issue 15364 + {"0e348", "0", nil}, // issue 15364 + {"-0e291", "-0", nil}, + {"-0e292", "-0", nil}, + {"-0e347", "-0", nil}, + {"-0e348", "-0", nil}, + // NaNs {"nan", "NaN", nil}, {"NaN", "NaN", nil}, -- cgit v1.3