]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/floating_point_powf.rs
Add 'src/tools/rustfmt/' from commit '7872306edf2e11a69aaffb9434088fd66b46a863'
[rust.git] / src / tools / clippy / tests / ui / floating_point_powf.rs
1 // run-rustfix
2 #![warn(clippy::suboptimal_flops, clippy::imprecise_flops)]
3
4 fn main() {
5     let x = 3f32;
6     let _ = 2f32.powf(x);
7     let _ = 2f32.powf(3.1);
8     let _ = 2f32.powf(-3.1);
9     let _ = std::f32::consts::E.powf(x);
10     let _ = std::f32::consts::E.powf(3.1);
11     let _ = std::f32::consts::E.powf(-3.1);
12     let _ = x.powf(1.0 / 2.0);
13     let _ = x.powf(1.0 / 3.0);
14     let _ = x.powf(3.0);
15     let _ = x.powf(-2.0);
16     let _ = x.powf(16_777_215.0);
17     let _ = x.powf(-16_777_215.0);
18     // Cases where the lint shouldn't be applied
19     let _ = x.powf(2.1);
20     let _ = x.powf(-2.1);
21     let _ = x.powf(16_777_216.0);
22     let _ = x.powf(-16_777_216.0);
23
24     let x = 3f64;
25     let _ = 2f64.powf(x);
26     let _ = 2f64.powf(3.1);
27     let _ = 2f64.powf(-3.1);
28     let _ = std::f64::consts::E.powf(x);
29     let _ = std::f64::consts::E.powf(3.1);
30     let _ = std::f64::consts::E.powf(-3.1);
31     let _ = x.powf(1.0 / 2.0);
32     let _ = x.powf(1.0 / 3.0);
33     let _ = x.powf(3.0);
34     let _ = x.powf(-2.0);
35     let _ = x.powf(-2_147_483_648.0);
36     let _ = x.powf(2_147_483_647.0);
37     // Cases where the lint shouldn't be applied
38     let _ = x.powf(2.1);
39     let _ = x.powf(-2.1);
40     let _ = x.powf(-2_147_483_649.0);
41     let _ = x.powf(2_147_483_648.0);
42 }