1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 // Dim returns the maximum of x-y or 0.
10 // Dim(+Inf, +Inf) = NaN
11 // Dim(-Inf, -Inf) = NaN
12 // Dim(x, NaN) = Dim(NaN, x) = NaN
13 func Dim(x, y float64) float64 {
14 // The special cases result in NaN after the subtraction:
24 // v is positive or NaN
28 // Max returns the larger of x or y.
31 // Max(x, +Inf) = Max(+Inf, x) = +Inf
32 // Max(x, NaN) = Max(NaN, x) = NaN
33 // Max(+0, ±0) = Max(±0, +0) = +0
35 func Max(x, y float64) float64 {
39 func max(x, y float64) float64 {
42 case IsInf(x, 1) || IsInf(y, 1):
44 case IsNaN(x) || IsNaN(y):
46 case x == 0 && x == y:
58 // Min returns the smaller of x or y.
61 // Min(x, -Inf) = Min(-Inf, x) = -Inf
62 // Min(x, NaN) = Min(NaN, x) = NaN
63 // Min(-0, ±0) = Min(±0, -0) = -0
64 func Min(x, y float64) float64 {
68 func min(x, y float64) float64 {
71 case IsInf(x, -1) || IsInf(y, -1):
73 case IsNaN(x) || IsNaN(y):
75 case x == 0 && x == y: