Source file
src/math/dim.go
1
2
3
4
5 package math
6
7
8
9
10
11
12
13
14 func Dim(x, y float64) float64 {
15
16
17
18
19
20 v := x - y
21 if v <= 0 {
22
23 return 0
24 }
25
26 return v
27 }
28
29
30
31
32
33
34
35
36
37
38
39
40 func Max(x, y float64) float64 {
41 if haveArchMax {
42 return archMax(x, y)
43 }
44 return max(x, y)
45 }
46
47 func max(x, y float64) float64 {
48
49 switch {
50 case IsInf(x, 1) || IsInf(y, 1):
51 return Inf(1)
52 case IsNaN(x) || IsNaN(y):
53 return NaN()
54 case x == 0 && x == y:
55 if Signbit(x) {
56 return y
57 }
58 return x
59 }
60 if x > y {
61 return x
62 }
63 return y
64 }
65
66
67
68
69
70
71
72
73
74
75
76 func Min(x, y float64) float64 {
77 if haveArchMin {
78 return archMin(x, y)
79 }
80 return min(x, y)
81 }
82
83 func min(x, y float64) float64 {
84
85 switch {
86 case IsInf(x, -1) || IsInf(y, -1):
87 return Inf(-1)
88 case IsNaN(x) || IsNaN(y):
89 return NaN()
90 case x == 0 && x == y:
91 if Signbit(x) {
92 return x
93 }
94 return y
95 }
96 if x < y {
97 return x
98 }
99 return y
100 }
101
View as plain text