Skip to content

Commit

Permalink
Unrolled build for rust-lang#124609
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#124609 - RalfJung:float-precision, r=cuviper

variable-precision float operations can differ depending on optimization levels

Follow-up to rust-lang#121793 and rust-lang#118217 that accounts for optimizations changing the precision of these functions.

Fixes rust-lang#109118
Fixes rust-lang#71355
  • Loading branch information
rust-timer authored May 3, 2024
2 parents 79734f1 + ff2ff97 commit 17a3434
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 116 deletions.
145 changes: 87 additions & 58 deletions library/std/src/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,10 @@ impl f32 {
/// It might have a different sequence of rounding operations than `powf`,
/// so the results are not guaranteed to agree.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
///
/// # Examples
///
Expand All @@ -393,9 +394,10 @@ impl f32 {

/// Raises a number to a floating point power.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
///
/// # Examples
///
Expand Down Expand Up @@ -444,9 +446,10 @@ impl f32 {

/// Returns `e^(self)`, (the exponential function).
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
///
/// # Examples
///
Expand All @@ -470,9 +473,10 @@ impl f32 {

/// Returns `2^(self)`.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
///
/// # Examples
///
Expand All @@ -494,9 +498,10 @@ impl f32 {

/// Returns the natural logarithm of the number.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
///
/// # Examples
///
Expand Down Expand Up @@ -524,9 +529,10 @@ impl f32 {
/// `self.log2()` can produce more accurate results for base 2, and
/// `self.log10()` can produce more accurate results for base 10.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
///
/// # Examples
///
Expand All @@ -548,9 +554,10 @@ impl f32 {

/// Returns the base 2 logarithm of the number.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
///
/// # Examples
///
Expand All @@ -572,9 +579,10 @@ impl f32 {

/// Returns the base 10 logarithm of the number.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
///
/// # Examples
///
Expand All @@ -599,9 +607,10 @@ impl f32 {
/// * If `self <= other`: `0.0`
/// * Else: `self - other`
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
/// This function currently corresponds to the `fdimf` from libc on Unix
/// and Windows. Note that this might change in the future.
///
Expand Down Expand Up @@ -637,9 +646,10 @@ impl f32 {

/// Returns the cube root of a number.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
/// This function currently corresponds to the `cbrtf` from libc on Unix
/// and Windows. Note that this might change in the future.
///
Expand All @@ -666,9 +676,10 @@ impl f32 {
/// right-angle triangle with other sides having length `x.abs()` and
/// `y.abs()`.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
/// This function currently corresponds to the `hypotf` from libc on Unix
/// and Windows. Note that this might change in the future.
///
Expand All @@ -693,9 +704,10 @@ impl f32 {

/// Computes the sine of a number (in radians).
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
///
/// # Examples
///
Expand All @@ -716,9 +728,10 @@ impl f32 {

/// Computes the cosine of a number (in radians).
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
///
/// # Examples
///
Expand All @@ -739,9 +752,10 @@ impl f32 {

/// Computes the tangent of a number (in radians).
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
/// This function currently corresponds to the `tanf` from libc on Unix and
/// Windows. Note that this might change in the future.
///
Expand All @@ -765,9 +779,10 @@ impl f32 {
/// the range [-pi/2, pi/2] or NaN if the number is outside the range
/// [-1, 1].
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
/// This function currently corresponds to the `asinf` from libc on Unix
/// and Windows. Note that this might change in the future.
///
Expand All @@ -794,9 +809,10 @@ impl f32 {
/// the range [0, pi] or NaN if the number is outside the range
/// [-1, 1].
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
/// This function currently corresponds to the `acosf` from libc on Unix
/// and Windows. Note that this might change in the future.
///
Expand All @@ -822,9 +838,10 @@ impl f32 {
/// Computes the arctangent of a number. Return value is in radians in the
/// range [-pi/2, pi/2];
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
/// This function currently corresponds to the `atanf` from libc on Unix
/// and Windows. Note that this might change in the future.
///
Expand Down Expand Up @@ -854,9 +871,10 @@ impl f32 {
/// * `y >= 0`: `arctan(y/x) + pi` -> `(pi/2, pi]`
/// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)`
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
/// This function currently corresponds to the `atan2f` from libc on Unix
/// and Windows. Note that this might change in the future.
///
Expand Down Expand Up @@ -890,9 +908,10 @@ impl f32 {
/// Simultaneously computes the sine and cosine of the number, `x`. Returns
/// `(sin(x), cos(x))`.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
/// This function currently corresponds to the `(f32::sin(x),
/// f32::cos(x))`. Note that this might change in the future.
///
Expand All @@ -919,9 +938,10 @@ impl f32 {
/// Returns `e^(self) - 1` in a way that is accurate even if the
/// number is close to zero.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
/// This function currently corresponds to the `expm1f` from libc on Unix
/// and Windows. Note that this might change in the future.
///
Expand All @@ -947,9 +967,10 @@ impl f32 {
/// Returns `ln(1+n)` (natural logarithm) more accurately than if
/// the operations were performed separately.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
/// This function currently corresponds to the `log1pf` from libc on Unix
/// and Windows. Note that this might change in the future.
///
Expand All @@ -975,9 +996,10 @@ impl f32 {

/// Hyperbolic sine function.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
/// This function currently corresponds to the `sinhf` from libc on Unix
/// and Windows. Note that this might change in the future.
///
Expand All @@ -1004,9 +1026,10 @@ impl f32 {

/// Hyperbolic cosine function.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
/// This function currently corresponds to the `coshf` from libc on Unix
/// and Windows. Note that this might change in the future.
///
Expand All @@ -1033,9 +1056,10 @@ impl f32 {

/// Hyperbolic tangent function.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
/// This function currently corresponds to the `tanhf` from libc on Unix
/// and Windows. Note that this might change in the future.
///
Expand All @@ -1062,9 +1086,10 @@ impl f32 {

/// Inverse hyperbolic sine function.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
///
/// # Examples
///
Expand All @@ -1089,9 +1114,10 @@ impl f32 {

/// Inverse hyperbolic cosine function.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
///
/// # Examples
///
Expand All @@ -1118,9 +1144,10 @@ impl f32 {

/// Inverse hyperbolic tangent function.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
///
/// # Examples
///
Expand All @@ -1143,9 +1170,10 @@ impl f32 {

/// Gamma function.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
/// This function currently corresponds to the `tgammaf` from libc on Unix
/// and Windows. Note that this might change in the future.
///
Expand All @@ -1171,9 +1199,10 @@ impl f32 {
///
/// The integer part of the tuple indicates the sign of the gamma function.
///
/// # Platform-specific precision
/// # Unspecified precision
///
/// The precision of this function varies by platform and Rust version.
/// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
/// can even differ within the same execution from one invocation to the next.
/// This function currently corresponds to the `lgamma_r` from libc on Unix
/// and Windows. Note that this might change in the future.
///
Expand Down
Loading

0 comments on commit 17a3434

Please sign in to comment.