fmt: %#v
does not print “a Go-syntax representation” for NaN values
#51486
Labels
FixPending
Issues that have a fix which has not yet been reviewed or submitted.
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
Format a floating-point NaN value with
%#v
(https://go.dev/play/p/zlxs4NzQ0bl?v=gotip):What did you expect to see?
Per https://pkg.go.dev/fmt#hdr-Printing, “a Go-syntax representation of the value” — that is, valid Go syntax for the value.
Perhaps a line like:
or
What did you see instead?
The string
NaN
:which is not “a Go-syntax representation”. Feeding it back into the program gives (https://go.dev/play/p/908uCl2KbVN?v=gotip):
This problem is especially acute if the NaN value is not the same bits as
math.NaN()
(https://go.dev/play/p/Xl13miTI7pe?v=gotip), since there is no indication that there is anything unusual about it.The text was updated successfully, but these errors were encountered: