File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -271,6 +271,9 @@ func ParseBestEffort(s string) float64 {
271271 if i >= uint (len (s )) {
272272 // the fractional part may be elided to remain compliant
273273 // with https://go.dev/ref/spec#Floating-point_literals
274+ if minus {
275+ f = - f
276+ }
274277 return f
275278 }
276279 k := i
@@ -429,6 +432,9 @@ func Parse(s string) (float64, error) {
429432 if i >= uint (len (s )) {
430433 // the fractional part might be elided to remain compliant
431434 // with https://go.dev/ref/spec#Floating-point_literals
435+ if minus {
436+ f = - f
437+ }
432438 return f , nil
433439 }
434440 k := i
Original file line number Diff line number Diff line change @@ -264,6 +264,7 @@ func TestParseBestEffort(t *testing.T) {
264264 f ("12." , 12 )
265265 f (".12" , 0.12 )
266266 f ("-.12" , - 0.12 )
267+ f ("-1234." , - 1234 )
267268 f ("12345.12345678901" , 12345.12345678901 )
268269 f ("12345.123456789012" , 12345.123456789012 )
269270 f ("12345.1234567890123" , 12345.1234567890123 )
@@ -417,6 +418,7 @@ func TestParseSuccess(t *testing.T) {
417418 f ("12." , 12 )
418419 f (".12" , 0.12 )
419420 f ("-.12" , - 0.12 )
421+ f ("-1234." , - 1234 )
420422 f ("12345.12345678901" , 12345.12345678901 )
421423 f ("12345.123456789012" , 12345.123456789012 )
422424 f ("12345.1234567890123" , 12345.1234567890123 )
You can’t perform that action at this time.
0 commit comments