luaur_code_gen/functions/safe_integer_constant.rs
1pub fn safe_integer_constant(value: f64) -> bool {
2 // Within 32 bits, note that we allow both max unsigned number as well as a negative counterpart
3 // Doubles are actually ok within even larger bounds (but not exactly 2^53), but we use the function in 32 bit optimizations
4 if value < -4294967295.0 || value > 4294967295.0 {
5 return false;
6 }
7
8 (value as i64 as f64) == value
9}