Skip to content

Commit a6f181d

Browse files
Fix atan2 inaccuracy in documentation
1 parent 76c5ed2 commit a6f181d

File tree

4 files changed

+44
-8
lines changed

4 files changed

+44
-8
lines changed

library/std/src/num/f128.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,17 @@ impl f128 {
559559
///
560560
/// * `x = 0`, `y = 0`: `0`
561561
/// * `x >= 0`: `arctan(y/x)` -> `[-pi/2, pi/2]`
562-
/// * `y >= 0`: `arctan(y/x) + pi` -> `(pi/2, pi]`
563-
/// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)`
562+
/// * `x < 0`, `y >= 0`: `arctan(y/x) + pi` -> `(pi/2, pi]`
563+
/// * `x <= 0`, `y < 0`: `arctan(y/x) - pi` -> `[-pi, -pi/2)`
564+
///
565+
/// # Special cases involving zeros
566+
///
567+
/// When one or both arguments are zero, the result depends on their signs:
568+
///
569+
/// * `atan2(0.0, 0.0) = 0.0`
570+
/// * `atan2(-0.0, 0.0) = -0.0`
571+
/// * `atan2(0.0, -0.0) = pi`
572+
/// * `atan2(-0.0, -0.0) = -pi`
564573
///
565574
/// # Unspecified precision
566575
///

library/std/src/num/f16.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,17 @@ impl f16 {
524524
///
525525
/// * `x = 0`, `y = 0`: `0`
526526
/// * `x >= 0`: `arctan(y/x)` -> `[-pi/2, pi/2]`
527-
/// * `y >= 0`: `arctan(y/x) + pi` -> `(pi/2, pi]`
528-
/// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)`
527+
/// * `x < 0`, `y >= 0`: `arctan(y/x) + pi` -> `(pi/2, pi]`
528+
/// * `x <= 0`, `y < 0`: `arctan(y/x) - pi` -> `[-pi, -pi/2)`
529+
///
530+
/// # Special cases involving zeros
531+
///
532+
/// When one or both arguments are zero, the result depends on their signs:
533+
///
534+
/// * `atan2(0.0, 0.0) = 0.0`
535+
/// * `atan2(-0.0, 0.0) = -0.0`
536+
/// * `atan2(0.0, -0.0) = pi`
537+
/// * `atan2(-0.0, -0.0) = -pi`
529538
///
530539
/// # Unspecified precision
531540
///

library/std/src/num/f32.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,8 +828,17 @@ impl f32 {
828828
///
829829
/// * `x = 0`, `y = 0`: `0`
830830
/// * `x >= 0`: `arctan(y/x)` -> `[-pi/2, pi/2]`
831-
/// * `y >= 0`: `arctan(y/x) + pi` -> `(pi/2, pi]`
832-
/// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)`
831+
/// * `x < 0`, `y >= 0`: `arctan(y/x) + pi` -> `(pi/2, pi]`
832+
/// * `x <= 0`, `y < 0`: `arctan(y/x) - pi` -> `[-pi, -pi/2)`
833+
///
834+
/// # Special cases involving zeros
835+
///
836+
/// When one or both arguments are zero, the result depends on their signs:
837+
///
838+
/// * `atan2(0.0, 0.0) = 0.0`
839+
/// * `atan2(-0.0, 0.0) = -0.0`
840+
/// * `atan2(0.0, -0.0) = pi`
841+
/// * `atan2(-0.0, -0.0) = -pi`
833842
///
834843
/// # Unspecified precision
835844
///

library/std/src/num/f64.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,8 +828,17 @@ impl f64 {
828828
///
829829
/// * `x = 0`, `y = 0`: `0`
830830
/// * `x >= 0`: `arctan(y/x)` -> `[-pi/2, pi/2]`
831-
/// * `y >= 0`: `arctan(y/x) + pi` -> `(pi/2, pi]`
832-
/// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)`
831+
/// * `x < 0`, `y >= 0`: `arctan(y/x) + pi` -> `(pi/2, pi]`
832+
/// * `x <= 0`, `y < 0`: `arctan(y/x) - pi` -> `[-pi, -pi/2)`
833+
///
834+
/// # Special cases involving zeros
835+
///
836+
/// When one or both arguments are zero, the result depends on their signs:
837+
///
838+
/// * `atan2(0.0, 0.0) = 0.0`
839+
/// * `atan2(-0.0, 0.0) = -0.0`
840+
/// * `atan2(0.0, -0.0) = pi`
841+
/// * `atan2(-0.0, -0.0) = -pi`
833842
///
834843
/// # Unspecified precision
835844
///

0 commit comments

Comments
 (0)