Skip to content

Commit

Permalink
Removed featyre(core_instrincts) (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dicklessgreat authored Nov 7, 2024
1 parent da68440 commit cd8d893
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 0 additions & 1 deletion dasp_sample/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//! are based.
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(feature = "std"), feature(core_intrinsics))]

#[cfg(not(feature = "std"))]
extern crate alloc;
Expand Down
12 changes: 10 additions & 2 deletions dasp_sample/src/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ pub mod f32 {

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

#[cfg(not(feature = "std"))]
pub fn sqrt(x: f64) -> f64 {
unsafe { core::intrinsics::sqrtf64(x) }
if x >= 0.0 {
f64::from_bits((x.to_bits() + 0x3f80_0000) >> 1)
} else {
f64::NAN
}
}
#[cfg(feature = "std")]
pub fn sqrt(x: f64) -> f64 {
Expand Down

0 comments on commit cd8d893

Please sign in to comment.