| 1 | /// Rounds the number toward 0 to the closest integral value (f32). |
| 2 | /// |
| 3 | /// This effectively removes the decimal part of the number, leaving the integral part. |
| 4 | #[cfg_attr (all(test, assert_no_panic), no_panic::no_panic)] |
| 5 | pub fn truncf(x: f32) -> f32 { |
| 6 | select_implementation! { |
| 7 | name: truncf, |
| 8 | use_arch: all(target_arch = "wasm32" , intrinsics_enabled), |
| 9 | args: x, |
| 10 | } |
| 11 | |
| 12 | super::generic::trunc(x) |
| 13 | } |
| 14 | |
| 15 | // PowerPC tests are failing on LLVM 13: https://github.com/rust-lang/rust/issues/88520 |
| 16 | #[cfg (not(target_arch = "powerpc64" ))] |
| 17 | #[cfg (test)] |
| 18 | mod tests { |
| 19 | #[test ] |
| 20 | fn sanity_check() { |
| 21 | assert_eq!(super::truncf(1.1), 1.0); |
| 22 | } |
| 23 | } |
| 24 | |