2023-04-20 14:37:15 +00:00
|
|
|
//@run-rustfix
|
2020-02-21 02:32:06 +00:00
|
|
|
#![warn(clippy::lossy_float_literal)]
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// Lossy whole-number float literals
|
|
|
|
let _: f32 = 16_777_216.0;
|
|
|
|
let _: f32 = 16_777_220.0;
|
|
|
|
let _: f32 = 16_777_220.0;
|
|
|
|
let _: f32 = 16_777_220.0;
|
|
|
|
let _ = 16_777_220_f32;
|
|
|
|
let _: f32 = -16_777_220.0;
|
|
|
|
let _: f64 = 9_007_199_254_740_992.0;
|
|
|
|
let _: f64 = 9_007_199_254_740_992.0;
|
|
|
|
let _: f64 = 9_007_199_254_740_992.0;
|
|
|
|
let _ = 9_007_199_254_740_992_f64;
|
|
|
|
let _: f64 = -9_007_199_254_740_992.0;
|
|
|
|
|
|
|
|
// Lossless whole number float literals
|
|
|
|
let _: f32 = 16_777_216.0;
|
|
|
|
let _: f32 = 16_777_218.0;
|
|
|
|
let _: f32 = 16_777_220.0;
|
|
|
|
let _: f32 = -16_777_216.0;
|
|
|
|
let _: f32 = -16_777_220.0;
|
|
|
|
let _: f64 = 16_777_217.0;
|
|
|
|
let _: f64 = -16_777_217.0;
|
|
|
|
let _: f64 = 9_007_199_254_740_992.0;
|
|
|
|
let _: f64 = -9_007_199_254_740_992.0;
|
|
|
|
|
|
|
|
// Ignored whole number float literals
|
|
|
|
let _: f32 = 1e25;
|
|
|
|
let _: f32 = 1E25;
|
|
|
|
let _: f64 = 1e99;
|
|
|
|
let _: f64 = 1E99;
|
|
|
|
let _: f32 = 0.1;
|
|
|
|
}
|