Skip to content

f64::log precision change in 1.82 nightly #128386

Closed
@ogoffart

Description

@ogoffart

Our CI started to report an error today with nightly on Linux (other platforms are fine).
Simplified the test case is because of a small difference in the computation of log.

(I know it's bad practice to do equality tests on float, but I thought I'd report this behavior change anyway as i don't know if this was intentional).

Code

I tried this code:

fn main() {
    println!("Hello, world! {}", 9f64.log(3.) );
    assert_eq!(9f64.log(3.) , 2.)
}

I expected to see this happen:

Hello, world! 2 and no panics. As this happens in stable

Instead, this happened:

Hello, world! 2.0000000000000004
thread 'main' panicked at src/main.rs:3:5:
assertion `left == right` failed
  left: 2.0000000000000004
 right: 2.0

Version with regression

rustc 1.82.0-nightly (612a33f 2024-07-29)
(Linux only)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-floating-pointArea: Floating point numbers and arithmeticC-bugCategory: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.regression-untriagedUntriaged performance or correctness regression.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions