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

Fix the atan family of functions behavior with bounds checks #143

Merged
merged 1 commit into from
May 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/math/atan2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ pub fn atan2(y: f64, x: f64) -> f64 {
}
}
/* |y/x| > 0x1p64 */
if ix + (64 << 20) < iy || iy == 0x7ff00000 {
if ix.wrapping_add(64 << 20) < iy || iy == 0x7ff00000 {
return if m & 1 != 0 { -PI / 2.0 } else { PI / 2.0 };
}

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