Skip to content

Rounding error with f64::from_str_radix #198

@TatriX

Description

@TatriX

Consider the following program:

use num::Num;

fn main() {
    let y = "2.89".parse::<f64>();
    println!("{:?}", y);
    let x = f64::from_str_radix("2.89", 10);
    println!("{:?}", x);
}

It prints:

Ok(2.89)
Ok(2.8899999999999997)

Am I missing anything here or results should be equal?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions