You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-floating-pointArea: Floating point numbers and arithmeticC-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.
The f64::atan2 function documentation specifies that the output could be in the range (-PI, PI]. However its not true. It could return -PI as well.
Following is from the function documentation:
Also, I think the fix here is pretty easy: as I see it, one just needs to mention that the sign of the result is the same as the sign of the first argument, and that -0 & +0 both exist with floats and are two slightly different things.
So probably just specify the output ranges for four of the cases:
x >= +0, y >= +0
x <= -0, y >= +0
x >= +0, y <= -0
x <= -0, y <= -0
Even though this issue is basically solved from what I can tell. I'm gonna give it a shot at solving it myself for practice to learn the contribution process ❤️
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-floating-pointArea: Floating point numbers and arithmeticC-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.
Activity
GrigorenkoPV commentedon Feb 17, 2025
From my testing,
f32::atan2(y, x).is_sign_positive() == y.is_sign_positive(). I was even able to make kani prove that for thelibmimplementation.@rustbot claim
I think I'll put up a PR adjusting documentation.
lolbinarycat commentedon Apr 9, 2025
triage: @GrigorenkoPV still planning on working on this?
also note that this should be updated for other float types too (f16, f32, and f128)
GrigorenkoPV commentedon Apr 14, 2025
I do, but not sure when I will have time, so I should probably unclaim this for now.
@rustbot release-assignment
Also, I think the fix here is pretty easy: as I see it, one just needs to mention that the sign of the result is the same as the sign of the first argument, and that
-0&+0both exist with floats and are two slightly different things.So probably just specify the output ranges for four of the cases:
x >= +0, y >= +0
x <= -0, y >= +0
x >= +0, y <= -0
x <= -0, y <= -0
@rustbot label +E-easy
as7erism commentedon Apr 14, 2025
@rustbot claim
DimitriiTrater commentedon Sep 11, 2025
@rustbot claim
QueenOfSquiggles commentedon Sep 28, 2025
Even though this issue is basically solved from what I can tell. I'm gonna give it a shot at solving it myself for practice to learn the contribution process ❤️
Rollup merge of rust-lang#146451 - DimitriiTrater:atan2_correctness_d…
Rollup merge of rust-lang#146451 - DimitriiTrater:atan2_correctness_d…
Rollup merge of rust-lang#146451 - DimitriiTrater:atan2_correctness_d…
Rollup merge of rust-lang#146451 - DimitriiTrater:atan2_correctness_d…
Rollup merge of rust-lang#146451 - DimitriiTrater:atan2_correctness_d…
Rollup merge of rust-lang#146451 - DimitriiTrater:atan2_correctness_d…
Rollup merge of rust-lang#146451 - DimitriiTrater:atan2_correctness_d…
Rollup merge of rust-lang#146451 - DimitriiTrater:atan2_correctness_d…
Unrolled build for #146451
Rollup merge of rust-lang#146451 - DimitriiTrater:atan2_correctness_d…