]> git.lizzy.rs Git - rust.git/blob - tests/ui/floating_point_powf.rs
`assertions_on_result_states` fix suggestion when `assert!` not in a statement
[rust.git] / 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 as f32).powf(1.0 / 3.0);
15     let _ = x.powf(3.0);
16     let _ = x.powf(-2.0);
17     let _ = x.powf(16_777_215.0);
18     let _ = x.powf(-16_777_215.0);
19     let _ = (x as f32).powf(-16_777_215.0);
20     let _ = (x as f32).powf(3.0);
21     let _ = (1.5_f32 + 1.0).powf(1.0 / 3.0);
22     let _ = 1.5_f64.powf(1.0 / 3.0);
23     let _ = 1.5_f64.powf(1.0 / 2.0);
24     let _ = 1.5_f64.powf(3.0);
25
26     // Cases where the lint shouldn't be applied
27     let _ = x.powf(2.1);
28     let _ = x.powf(-2.1);
29     let _ = x.powf(16_777_216.0);
30     let _ = x.powf(-16_777_216.0);
31
32     let x = 3f64;
33     let _ = 2f64.powf(x);
34     let _ = 2f64.powf(3.1);
35     let _ = 2f64.powf(-3.1);
36     let _ = std::f64::consts::E.powf(x);
37     let _ = std::f64::consts::E.powf(3.1);
38     let _ = std::f64::consts::E.powf(-3.1);
39     let _ = x.powf(1.0 / 2.0);
40     let _ = x.powf(1.0 / 3.0);
41     let _ = x.powf(3.0);
42     let _ = x.powf(-2.0);
43     let _ = x.powf(-2_147_483_648.0);
44     let _ = x.powf(2_147_483_647.0);
45     // Cases where the lint shouldn't be applied
46     let _ = x.powf(2.1);
47     let _ = x.powf(-2.1);
48     let _ = x.powf(-2_147_483_649.0);
49     let _ = x.powf(2_147_483_648.0);
50 }