1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
11 #![feature(tool_lints)]
12 #![warn(clippy::excessive_precision)]
13 #![allow(clippy::print_literal)]
17 const GOOD32: f32 = 0.123_456;
18 const GOOD32_SM: f32 = 0.000_000_000_1;
19 const GOOD32_DOT: f32 = 10_000_000_000.0;
20 const GOOD32_EDGE: f32 = 1.000_000_8;
21 const GOOD64: f64 = 0.123_456_789_012;
22 const GOOD64_SM: f32 = 0.000_000_000_000_000_1;
23 const GOOD64_DOT: f32 = 10_000_000_000_000_000.0;
25 const BAD32_1: f32 = 0.123_456_789_f32;
26 const BAD32_2: f32 = 0.123_456_789;
27 const BAD32_3: f32 = 0.100_000_000_000_1;
28 const BAD32_EDGE: f32 = 1.000_000_9;
30 const BAD64_1: f64 = 0.123_456_789_012_345_67f64;
31 const BAD64_2: f64 = 0.123_456_789_012_345_67;
32 const BAD64_3: f64 = 0.100_000_000_000_000_000_1;
35 println!("{:?}", 8.888_888_888_888_888_888_888);
37 // // TODO add inferred type tests for f32
39 let good32: f32 = 0.123_456_f32;
40 let good32_2: f32 = 0.123_456;
42 let good64: f64 = 0.123_456_789_012;
43 let good64_suf: f64 = 0.123_456_789_012f64;
44 let good64_inf = 0.123_456_789_012;
46 let bad32: f32 = 1.123_456_789;
47 let bad32_suf: f32 = 1.123_456_789_f32;
48 let bad32_inf = 1.123_456_789_f32;
50 let bad64: f64 = 0.123_456_789_012_345_67;
51 let bad64_suf: f64 = 0.123_456_789_012_345_67f64;
52 let bad64_inf = 0.123_456_789_012_345_67;
55 let good_vec32: Vec<f32> = vec![0.123_456];
56 let good_vec64: Vec<f64> = vec![0.123_456_789];
58 let bad_vec32: Vec<f32> = vec![0.123_456_789];
59 let bad_vec64: Vec<f64> = vec![0.123_456_789_123_456_789];
61 // Exponential float notation
62 let good_e32: f32 = 1e-10;
63 let bad_e32: f32 = 1.123_456_788_888e-10;
65 let good_bige32: f32 = 1E-10;
66 let bad_bige32: f32 = 1.123_456_788_888E-10;
69 let good_inferred: f32 = 1f32 * 1_000_000_000.;