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 5
5
//! are based.
6
6
7
7
#![ cfg_attr( not( feature = "std" ) , no_std) ]
8
- #![ cfg_attr( not( feature = "std" ) , feature( core_intrinsics) ) ]
9
8
10
9
#[ cfg( not( feature = "std" ) ) ]
11
10
extern crate alloc;
Original file line number Diff line number Diff line change @@ -4,7 +4,11 @@ pub mod f32 {
4
4
5
5
#[ cfg( not( feature = "std" ) ) ]
6
6
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
+ }
8
12
}
9
13
#[ cfg( feature = "std" ) ]
10
14
pub fn sqrt ( x : f32 ) -> f32 {
@@ -18,7 +22,11 @@ pub mod f64 {
18
22
19
23
#[ cfg( not( feature = "std" ) ) ]
20
24
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
+ }
22
30
}
23
31
#[ cfg( feature = "std" ) ]
24
32
pub fn sqrt ( x : f64 ) -> f64 {
You can’t perform that action at this time.
0 commit comments