From d763e4f73e271677a61c2bdbfbfcef262d150f22 Mon Sep 17 00:00:00 2001 From: Alisdair McDiarmid Date: Thu, 7 Jan 2021 16:29:49 -0500 Subject: [PATCH] cli: Fix rendering of long integers Recent changes to the human-readable rendering of outputs and console values led to long integer values being presented in scientific notation (e.g. 1.2345678e+07). While technically correct, this is an unusual way to present integer values. This commit changes the formatting mode to 'f', which never uses scientific notation and displays integer values as a sequence of digits instead (e.g. 12345678). --- repl/format.go | 2 +- repl/format_test.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/repl/format.go b/repl/format.go index d62622df6..14e09d708 100644 --- a/repl/format.go +++ b/repl/format.go @@ -52,7 +52,7 @@ func FormatValue(v cty.Value, indent int) string { return strconv.Quote(v.AsString()) case cty.Number: bf := v.AsBigFloat() - return bf.Text('g', -1) + return bf.Text('f', -1) case cty.Bool: if v.True() { return "true" diff --git a/repl/format_test.go b/repl/format_test.go index d0b6b8805..6d4e484bd 100644 --- a/repl/format_test.go +++ b/repl/format_test.go @@ -89,10 +89,22 @@ EOT_`, cty.NumberIntVal(5), `5`, }, + { + cty.NumberIntVal(1234567890), + `1234567890`, + }, { cty.NumberFloatVal(5.2), `5.2`, }, + { + cty.NumberFloatVal(123456789.0), + `123456789`, + }, + { + cty.NumberFloatVal(123456789.01), + `123456789.01`, + }, { cty.False, `false`,