(x: f64)
| 129 | clippy::cast_sign_loss |
| 130 | )] |
| 131 | fn round_f64(x: f64) -> f64 { |
| 132 | if x >= 0.0 { |
| 133 | let int_part = x as u64 as f64; |
| 134 | let frac = x - int_part; |
| 135 | if frac >= 0.5 { |
| 136 | int_part + 1.0 |
| 137 | } else { |
| 138 | int_part |
| 139 | } |
| 140 | } else { |
| 141 | let int_part = (-x) as u64 as f64; |
| 142 | let frac = -x - int_part; |
| 143 | if frac >= 0.5 { |
| 144 | -(int_part + 1.0) |
| 145 | } else { |
| 146 | -int_part |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | /// Write a u64 to string |
| 152 | pub fn write_u64(s: &mut String, mut n: u64) { |