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