rustgd / cgmath

A linear algebra and mathematics library for computer graphics.
https://docs.rs/cgmath
Apache License 2.0
1.12k stars 155 forks source link

println!("{:?}", Vector3) gives wrong values?! #540

Closed ghost closed 2 years ago

ghost commented 2 years ago

Hello,

I have this simple code:

use cgmath::Vector3;

fn main() {
    let test = Vector3::new(0.0, -0.0000000008739, 0.0);

    println!("{:?}", test);
}

You would expect that it prints this: Vector3 [0.0, -0.0000000008739, 0.0]

Instead it prints this: Vector3 [0.0, -8.739e-10, 0.0]

Am I doing something wrong?

Thanks in advance.

With kind regards, Lorenz

kvark commented 2 years ago

This is no specific to cgmath, that's what f32 debug output produces - https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f1c8488f7373c08e3229da21a910a352