compiler_builtins/math/libm_math/
floor.rs

1/// Floor (f16)
2///
3/// Finds the nearest integer less than or equal to `x`.
4#[cfg(f16_enabled)]
5#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
6pub fn floorf16(x: f16) -> f16 {
7    return super::generic::floor(x);
8}
9
10/// Floor (f64)
11///
12/// Finds the nearest integer less than or equal to `x`.
13#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
14pub fn floor(x: f64) -> f64 {
15    select_implementation! {
16        name: floor,
17        use_arch: all(target_arch = "wasm32", intrinsics_enabled),
18        use_arch_required: all(target_arch = "x86", not(target_feature = "sse2")),
19        args: x,
20    }
21
22    return super::generic::floor(x);
23}
24
25/// Floor (f32)
26///
27/// Finds the nearest integer less than or equal to `x`.
28#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
29pub fn floorf(x: f32) -> f32 {
30    select_implementation! {
31        name: floorf,
32        use_arch: all(target_arch = "wasm32", intrinsics_enabled),
33        args: x,
34    }
35
36    return super::generic::floor(x);
37}
38
39/// Floor (f128)
40///
41/// Finds the nearest integer less than or equal to `x`.
42#[cfg(f128_enabled)]
43#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
44pub fn floorf128(x: f128) -> f128 {
45    return super::generic::floor(x);
46}