mirror of
https://github.com/golang/go.git
synced 2025-05-14 11:54:38 +00:00
math: add function examples.
The function Modf lacks corresponding examples. Change-Id: Id93423500e87d35b0b6870882be1698b304797ae Reviewed-on: https://go-review.googlesource.com/c/go/+/231097 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
2d323f900d
commit
e90b0ce68b
@ -227,3 +227,14 @@ func ExampleCbrt() {
|
||||
// 2.00
|
||||
// 3.00
|
||||
}
|
||||
|
||||
func ExampleModf() {
|
||||
int, frac := math.Modf(3.14)
|
||||
fmt.Printf("%.2f, %.2f\n", int, frac)
|
||||
|
||||
int, frac = math.Modf(-2.71)
|
||||
fmt.Printf("%.2f, %.2f\n", int, frac)
|
||||
// Output:
|
||||
// 3.00, 0.14
|
||||
// -2.00, -0.71
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user