Skip to content

Commit f225e86

Browse files
committed
Also encode large floats as exponent syntax in toml-test integration
1 parent 10fb0a6 commit f225e86

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

decode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ func (md *MetaData) unifyString(data any, rv reflect.Value) error {
430430
if i, ok := data.(int64); ok {
431431
rv.SetString(strconv.FormatInt(i, 10))
432432
} else if f, ok := data.(float64); ok {
433-
rv.SetString(strconv.FormatFloat(f, 'f', -1, 64))
433+
rv.SetString(strconv.FormatFloat(f, 'g', -1, 64))
434434
} else {
435435
return md.badtype("string", data)
436436
}

internal/tag/add.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func Add(key string, tomlData any) any {
6969
case math.IsInf(orig, -1):
7070
return tag("float", "-inf")
7171
default:
72-
return tag("float", strconv.FormatFloat(orig, 'f', -1, 64))
72+
return tag("float", strconv.FormatFloat(orig, 'g', -1, 64))
7373
}
7474
}
7575
}

0 commit comments

Comments
 (0)