/build/cargo-vendor-dir/libm-0.2.15/src/math/rint.rs
Line | Count | Source |
1 | | use super::support::Round; |
2 | | |
3 | | /// Round `x` to the nearest integer, breaking ties toward even. |
4 | | #[cfg(f16_enabled)] |
5 | | #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] |
6 | | pub fn rintf16(x: f16) -> f16 { |
7 | | select_implementation! { |
8 | | name: rintf16, |
9 | | use_arch: all(target_arch = "aarch64", target_feature = "fp16"), |
10 | | args: x, |
11 | | } |
12 | | |
13 | | super::generic::rint_round(x, Round::Nearest).val |
14 | | } |
15 | | |
16 | | /// Round `x` to the nearest integer, breaking ties toward even. |
17 | | #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] |
18 | 29 | pub fn rintf(x: f32) -> f32 { |
19 | 29 | select_implementation! { |
20 | 29 | name: rintf, |
21 | 29 | use_arch: any( |
22 | 29 | all(target_arch = "aarch64", target_feature = "neon"), |
23 | 29 | all(target_arch = "wasm32", intrinsics_enabled), |
24 | 29 | ), |
25 | 29 | args: x, |
26 | 29 | } |
27 | 29 | |
28 | 29 | super::generic::rint_round(x, Round::Nearest).val |
29 | 29 | } |
30 | | |
31 | | /// Round `x` to the nearest integer, breaking ties toward even. |
32 | | #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] |
33 | 29 | pub fn rint(x: f64) -> f64 { |
34 | 29 | select_implementation! { |
35 | 29 | name: rint, |
36 | 29 | use_arch: any( |
37 | 29 | all(target_arch = "aarch64", target_feature = "neon"), |
38 | 29 | all(target_arch = "wasm32", intrinsics_enabled), |
39 | 29 | ), |
40 | 29 | args: x, |
41 | 29 | } |
42 | 29 | |
43 | 29 | super::generic::rint_round(x, Round::Nearest).val |
44 | 29 | } |
45 | | |
46 | | /// Round `x` to the nearest integer, breaking ties toward even. |
47 | | #[cfg(f128_enabled)] |
48 | | #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] |
49 | | pub fn rintf128(x: f128) -> f128 { |
50 | | super::generic::rint_round(x, Round::Nearest).val |
51 | | } |