hcl/json: decode number literals at full precision

Elsewhere we are using 512-bit precision as the standard for converting
from a string to a number, since the default is shorter. This is just to
unify JSON parsing with the native syntax processing and the automatic
type conversions in the language, so we don't see different precision
behaviors depending on syntax.
This commit is contained in:
Martin Atkins 2018-02-27 07:54:56 -08:00
parent 75cceef4f0
commit 998a3053e2

View File

@ -370,7 +370,7 @@ func parseNumber(p *peeker) (node, hcl.Diagnostics) {
}
}
f, _, err := (&big.Float{}).Parse(string(num), 10)
f, _, err := big.ParseFloat(string(num), 10, 512, big.ToNearestEven)
if err != nil {
// Should never happen if above passed, since JSON numbers are a subset
// of what big.Float can parse...