File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change 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" ) ) ]
1110extern crate alloc;
Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments