-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath_example_test.go
More file actions
56 lines (45 loc) · 906 Bytes
/
math_example_test.go
File metadata and controls
56 lines (45 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* Package lol
* @Author iFurySt <ifuryst@gmail.com>
* @Date 2023/7/20
*/
package lol
import (
"fmt"
)
func ExampleAbs() {
xFloat64 := Abs(float64(-2))
fmt.Printf("%.1f, %T\n", xFloat64, xFloat64)
yFloat64 := Abs(float64(2))
fmt.Printf("%.1f, %T\n", yFloat64, yFloat64)
xInt := Abs(int(-2))
fmt.Printf("%d, %T\n", xInt, xInt)
yInt := Abs(int(2))
fmt.Printf("%d, %T\n", yInt, yInt)
type int64Type int64
xTypeInt64 := Abs(int64Type(-2))
fmt.Printf("%d, %T\n", xTypeInt64, xTypeInt64)
yTypeInt64 := Abs(int64Type(2))
fmt.Printf("%d, %T\n", yTypeInt64, yTypeInt64)
// Output:
// 2.0, float64
// 2.0, float64
// 2, int
// 2, int
// 2, lol.int64Type
// 2, lol.int64Type
}
func ExampleMax() {
fmt.Println(Max(3, 1))
fmt.Println(Max(3.3, -1.0))
// Output:
// 3
// 3.3
}
func ExampleMin() {
fmt.Println(Min(3, 1))
fmt.Println(Min(3.3, -1.0))
// Output:
// 1
// -1
}