From 36fb6160ae128489c4fd793d7359370ea3eaf992 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Sun, 21 Jan 2024 17:20:02 +1100 Subject: [PATCH] fmt: document how %#g handles infinities and NaNs The %#g format prints a "Go-syntax representation", but there is no such thing for IEEE754 infinities and NaNs, so just document what happens, which is that it prints +Inf, -Inf, or NaN. We could show something like math.Inf(1) and math.Nan(), but that doesn't sit right, and anyway for NaNs you can't even recover the original value. Simpler and more honest to give up. Fixes #51486 Change-Id: I8d4e8186f5d7acc3e0e7b51d0b322142908ea0a2 Reviewed-on: https://go-review.googlesource.com/c/go/+/557235 Run-TryBot: Rob Pike Reviewed-by: Russ Cox TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor --- src/fmt/doc.go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fmt/doc.go b/src/fmt/doc.go index ea2da97da6..c47bee1080 100644 --- a/src/fmt/doc.go +++ b/src/fmt/doc.go @@ -16,6 +16,7 @@ General: %v the value in a default format when printing structs, the plus flag (%+v) adds field names %#v a Go-syntax representation of the value + (floating-point infinities and NaNs print as ±Inf and NaN) %T a Go-syntax representation of the type of the value %% a literal percent sign; consumes no value -- 2.48.1