cue icon indicating copy to clipboard operation
cue copied to clipboard

strconv.FormatFloat fails with zero (0.0)

Open kcburge opened this issue 2 years ago • 3 comments

What version of CUE are you using (cue version)?

master 00c5ddf5

Does this issue reproduce with the latest release?

Yes

What did you do?

t6: strconv.FormatFloat(0.0, 102, -1, 64)

What did you expect to see?

"0"

What did you see instead?

cannot use 0.0 (type float) as float64 in argument 0 to strconv.FormatFloat: value was rounded down

kcburge avatar Apr 26 '22 23:04 kcburge

Note: this also happens with strconv.FormatFloat(0, 103, -1, 64) (it's not about the fact that it's a floating point literal).

rogpeppe avatar Apr 28 '22 17:04 rogpeppe

Related to #1670

mpvl avatar May 18 '22 07:05 mpvl

The proposed fix also fixes decoding number values 0 or 0.0 into Go struct fields of type float64 (using cue.Value.Decode).

knieriem avatar May 18 '22 10:05 knieriem