summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/cast_precision_loss.txt
blob: f915d9f8a6d0d2bd191bfd7ea43e3b17fa36c22c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
### What it does
Checks for casts from any numerical to a float type where
the receiving type cannot store all values from the original type without
rounding errors. This possible rounding is to be expected, so this lint is
`Allow` by default.

Basically, this warns on casting any integer with 32 or more bits to `f32`
or any 64-bit integer to `f64`.

### Why is this bad?
It's not bad at all. But in some applications it can be
helpful to know where precision loss can take place. This lint can help find
those places in the code.

### Example
```
let x = u64::MAX;
x as f64;
```