mirror of
https://github.com/golang/go
synced 2024-11-23 12:40:11 -07:00
strconv: show what fmt package uses for float printing
The strconv docs are not very helpful for people who just want to pick a reasonable default, for example the one used by the fmt package to show floats. Add an example illustrating what the fmt package uses. Change-Id: Iefefa70dfd4d4bfa9962a20654ee23662818ef38 Reviewed-on: https://go-review.googlesource.com/c/go/+/463980 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com>
This commit is contained in:
parent
f298b90bc5
commit
e1f9499ecf
@ -134,9 +134,14 @@ func ExampleFormatFloat() {
|
||||
s64 := strconv.FormatFloat(v, 'E', -1, 64)
|
||||
fmt.Printf("%T, %v\n", s64, s64)
|
||||
|
||||
// fmt.Println uses these arguments to print floats
|
||||
fmt64 := strconv.FormatFloat(v, 'g', -1, 64)
|
||||
fmt.Printf("%T, %v\n", fmt64, fmt64)
|
||||
|
||||
// Output:
|
||||
// string, 3.1415927E+00
|
||||
// string, 3.1415926535E+00
|
||||
// string, 3.1415926535
|
||||
}
|
||||
|
||||
func ExampleFormatInt() {
|
||||
|
Loading…
Reference in New Issue
Block a user