Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 50f854a

Browse files
authored
Merge pull request #143 from mb64/wrapping-atan2
Fix the atan family of functions behavior with bounds checks
2 parents 249a9ee + 1dbd731 commit 50f854a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libm/src/math/atan2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ pub fn atan2(y: f64, x: f64) -> f64 {
9292
}
9393
}
9494
/* |y/x| > 0x1p64 */
95-
if ix + (64 << 20) < iy || iy == 0x7ff00000 {
95+
if ix.wrapping_add(64 << 20) < iy || iy == 0x7ff00000 {
9696
return if m & 1 != 0 { -PI / 2.0 } else { PI / 2.0 };
9797
}
9898

9999
/* z = atan(|y/x|) without spurious underflow */
100-
let z = if (m & 2 != 0) && iy + (64 << 20) < ix {
100+
let z = if (m & 2 != 0) && iy.wrapping_add(64 << 20) < ix {
101101
/* |y/x| < 0x1p-64, x<0 */
102102
0.0
103103
} else {

0 commit comments

Comments
 (0)