Source File
mod.go
Belonging Package
math
// Copyright 2009-2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package math
/*
Floating-point mod function.
*/
// Mod returns the floating-point remainder of x/y.
// The magnitude of the result is less than y and its
// sign agrees with that of x.
//
// Special cases are:
//
// Mod(±Inf, y) = NaN
// Mod(NaN, y) = NaN
// Mod(x, 0) = NaN
// Mod(x, ±Inf) = x
// Mod(x, NaN) = NaN
func (, float64) float64 {
if haveArchMod {
return archMod(, )
}
return mod(, )
}
func mod(, float64) float64 {
if == 0 || IsInf(, 0) || IsNaN() || IsNaN() {
return NaN()
}
= Abs()
, := Frexp()
:=
if < 0 {
= -
}
for >= {
, := Frexp()
if < {
= - 1
}
= - Ldexp(, -)
}
if < 0 {
= -
}
return
}
![]() |
The pages are generated with Golds v0.6.9-preview. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |