OSDN Git Service

libgo: Update to weekly.2011-12-06.
[pf3gnuchains/gcc-fork.git] / libgo / go / math / dim.go
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.
4
5 package math
6
7 // Dim returns the maximum of x-y or 0.
8 func Dim(x, y float64) float64 {
9         if x > y {
10                 return x - y
11         }
12         return 0
13 }
14
15 // Max returns the larger of x or y.
16 func Max(x, y float64) float64 {
17         if x > y {
18                 return x
19         }
20         return y
21 }
22
23 // Min returns the smaller of x or y.
24 func Min(x, y float64) float64 {
25         if x < y {
26                 return x
27         }
28         return y
29 }