We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ce46efe commit 456ac1cCopy full SHA for 456ac1c
dasp_sample/src/ops.rs
@@ -20,11 +20,7 @@ pub mod f32 {
20
#[cfg(not(feature = "std"))]
21
#[inline]
22
pub fn round(x: f32) -> f32 {
23
- if x >= 0.0 {
24
- (x + 0.5) as i32 as f32
25
- } else {
26
- (x - 0.5) as i32 as f32
27
- }
+ (x + 0.5_f32.copysign(x)) as i64 as f32
28
}
29
#[cfg(feature = "std")]
30
@@ -55,11 +51,7 @@ pub mod f64 {
55
51
56
52
57
53
pub fn round(x: f64) -> f64 {
58
59
- (x + 0.5) as i64 as f64
60
61
- (x - 0.5) as i64 as f64
62
54
+ (x + 0.5_f64.copysign(x)) as i64 as f64
63
64
65
0 commit comments