]> git.lizzy.rs Git - rust.git/blob - src/docs/excessive_precision.txt
[Arithmetic] Consider literals
[rust.git] / src / docs / excessive_precision.txt
1 ### What it does
2 Checks for float literals with a precision greater
3 than that supported by the underlying type.
4
5 ### Why is this bad?
6 Rust will truncate the literal silently.
7
8 ### Example
9 ```
10 let v: f32 = 0.123_456_789_9;
11 println!("{}", v); //  0.123_456_789
12 ```
13
14 Use instead:
15 ```
16 let v: f64 = 0.123_456_789_9;
17 println!("{}", v); //  0.123_456_789_9
18 ```