Skip to content

Commit cd8d893

Browse files
Removed featyre(core_instrincts) (#184)
1 parent da68440 commit cd8d893

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

dasp_sample/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
//! are based.
66
77
#![cfg_attr(not(feature = "std"), no_std)]
8-
#![cfg_attr(not(feature = "std"), feature(core_intrinsics))]
98

109
#[cfg(not(feature = "std"))]
1110
extern crate alloc;

dasp_sample/src/ops.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ pub mod f32 {
44

55
#[cfg(not(feature = "std"))]
66
pub fn sqrt(x: f32) -> f32 {
7-
unsafe { core::intrinsics::sqrtf32(x) }
7+
if x >= 0.0 {
8+
f32::from_bits((x.to_bits() + 0x3f80_0000) >> 1)
9+
} else {
10+
f32::NAN
11+
}
812
}
913
#[cfg(feature = "std")]
1014
pub fn sqrt(x: f32) -> f32 {
@@ -18,7 +22,11 @@ pub mod f64 {
1822

1923
#[cfg(not(feature = "std"))]
2024
pub fn sqrt(x: f64) -> f64 {
21-
unsafe { core::intrinsics::sqrtf64(x) }
25+
if x >= 0.0 {
26+
f64::from_bits((x.to_bits() + 0x3f80_0000) >> 1)
27+
} else {
28+
f64::NAN
29+
}
2230
}
2331
#[cfg(feature = "std")]
2432
pub fn sqrt(x: f64) -> f64 {

0 commit comments

Comments
 (0)