File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -271,6 +271,9 @@ func ParseBestEffort(s string) float64 {
271
271
if i >= uint (len (s )) {
272
272
// the fractional part may be elided to remain compliant
273
273
// with https://go.dev/ref/spec#Floating-point_literals
274
+ if minus {
275
+ f = - f
276
+ }
274
277
return f
275
278
}
276
279
k := i
@@ -429,6 +432,9 @@ func Parse(s string) (float64, error) {
429
432
if i >= uint (len (s )) {
430
433
// the fractional part might be elided to remain compliant
431
434
// with https://go.dev/ref/spec#Floating-point_literals
435
+ if minus {
436
+ f = - f
437
+ }
432
438
return f , nil
433
439
}
434
440
k := i
Original file line number Diff line number Diff line change @@ -264,6 +264,7 @@ func TestParseBestEffort(t *testing.T) {
264
264
f ("12." , 12 )
265
265
f (".12" , 0.12 )
266
266
f ("-.12" , - 0.12 )
267
+ f ("-1234." , - 1234 )
267
268
f ("12345.12345678901" , 12345.12345678901 )
268
269
f ("12345.123456789012" , 12345.123456789012 )
269
270
f ("12345.1234567890123" , 12345.1234567890123 )
@@ -417,6 +418,7 @@ func TestParseSuccess(t *testing.T) {
417
418
f ("12." , 12 )
418
419
f (".12" , 0.12 )
419
420
f ("-.12" , - 0.12 )
421
+ f ("-1234." , - 1234 )
420
422
f ("12345.12345678901" , 12345.12345678901 )
421
423
f ("12345.123456789012" , 12345.123456789012 )
422
424
f ("12345.1234567890123" , 12345.1234567890123 )
You can’t perform that action at this time.
0 commit comments