Gerrit Bot has uploaded this change for review.
fmt.doc: formatting functions will round the number according to the specified precision
Change-Id: I8bf602a7e58595b9c264b85ab8fc1d01fae1aee4
GitHub-Last-Rev: f629ff5f4fd7f40df5cb1cb43172f0de2bf24a9a
GitHub-Pull-Request: golang/go#60472
---
M src/fmt/doc.go
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/fmt/doc.go b/src/fmt/doc.go
index 9785ed9..0846f34 100644
--- a/src/fmt/doc.go
+++ b/src/fmt/doc.go
@@ -120,6 +120,10 @@
%6.3f prints 12.345 while %.3g prints 12.3. The default precision for %e, %f
and %#g is 6; for %g it is the smallest number of digits necessary to identify
the value uniquely.
+If the digit immediately following the precision position is 5 or greater, the
+number is rounded up. For example, given 12.345 the format
+%.2f prints 12.35, otherwise the number is rounded down (truncated). For example,
+given 12.341 the format %.2f prints 12.34.
For complex numbers, the width and precision apply to the two
components independently and the result is parenthesized, so %f applied
To view, visit change 498875. To unsubscribe, or for help writing mail filters, visit settings.
1 comment:
File src/fmt/doc.go:
Patch Set #1, Line 123: If the digit immediately following the precision position is 5 or greater, the
I don't know that this is true. It may depend on floating point rounding modes outside control of this package, and may also depend on later digits.
I'd prefer we not say anything about this here.
To view, visit change 498875. To unsubscribe, or for help writing mail filters, visit settings.
Patch Set #1, Line 123: If the digit immediately following the precision position is 5 or greater, the
I don't know that this is true. […]
I see, Thanks! I will close the PR then.
To view, visit change 498875. To unsubscribe, or for help writing mail filters, visit settings.