Note atan2 can return -PI#140487
Note atan2 can return -PI#140487as7erism wants to merge 1 commit intorust-lang:masterfrom as7erism:atan2-docs-correction
atan2 can return -PI#140487Conversation
|
rustbot has assigned @workingjubilee. Use |
atan2 can return -PI
| /// * `x <= -0`, `y <= -0` -> `[-pi, -pi/2]` | ||
| /// * `x >= +0`, `y <= -0` -> `[-pi/2, -0]` | ||
| /// | ||
| /// Note that positive and negative 0 are distinct floating point values. |
There was a problem hiding this comment.
This is always true, what's more important is that this description is not treating them as equal.
| /// * `x = 0`, `y = 0`: `0` | ||
| /// * `x >= 0`: `arctan(y/x)` -> `[-pi/2, pi/2]` | ||
| /// * `y >= 0`: `arctan(y/x) + pi` -> `(pi/2, pi]` | ||
| /// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)` | ||
| /// * `x >= +0`, `y >= +0` -> `[+0, pi/2]` | ||
| /// * `x <= -0`, `y >= +0` -> `[pi/2, pi]` | ||
| /// * `x <= -0`, `y <= -0` -> `[-pi, -pi/2]` | ||
| /// * `x >= +0`, `y <= -0` -> `[-pi/2, -0]` |
There was a problem hiding this comment.
println!("{}", f32::atan2(-0.0, 0.0)); // -0
println!("{}", f32::atan2(0.0, -0.0)); // 3.1415927
println!("{}", f32::atan2(0.0, 0.0)); // 0
println!("{}", f32::atan2(-0.0, -0.0)); // -3.1415927...that's kinda fucked up huh.
I think placing the comment about negative versus positive zero after this table-ish-thing makes it harder to read. We should lead with the comment that the sign of 0.0 can affect the result, rather than being treated as equal, even though (0.0 == -0.0) == true.
|
☔ The latest upstream changes (presumably #141739) made this pull request unmergeable. Please resolve the merge conflicts. |
Fixes #136275