1 // Copyright 2009-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.
8 Floating-point mod function.
11 // Mod returns the floating-point remainder of x/y.
12 // The magnitude of the result is less than y and its
13 // sign agrees with that of x.
16 // if x is not finite, Mod returns NaN
17 // if y is 0 or NaN, Mod returns NaN
18 func Mod(x, y float64) float64 {
19 // TODO(rsc): Remove manual inlining of IsNaN, IsInf
20 // when compiler does it for us.
21 if y == 0 || x > MaxFloat64 || x < -MaxFloat64 || x != x || y != y { // y == 0 || IsInf(x, 0) || IsNaN(x) || IsNan(y)
41 r = r - Ldexp(y, rexp-yexp)