We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f22c357 commit 497d241Copy full SHA for 497d241
src/math/mod.go
@@ -24,16 +24,12 @@ func mod(x, y float64) float64 {
24
if y == 0 || IsInf(x, 0) || IsNaN(x) || IsNaN(y) {
25
return NaN()
26
}
27
- if y < 0 {
28
- y = -y
29
- }
+ y = Abs(y)
30
31
yfr, yexp := Frexp(y)
32
- sign := false
33
r := x
34
if x < 0 {
35
r = -x
36
- sign = true
37
38
39
for r >= y {
@@ -43,7 +39,7 @@ func mod(x, y float64) float64 {
43
44
40
r = r - Ldexp(y, rexp-yexp)
45
41
46
- if sign {
42
+ if x < 0 {
47
r = -r
48
49
return r
0 commit comments