File tree Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -73,8 +73,7 @@ pub trait F32Ext: private::Sealed + Sized {
73
73
74
74
fn abs ( self ) -> Self ;
75
75
76
- // NOTE depends on unstable intrinsics::copysignf32
77
- // fn signum(self) -> Self;
76
+ fn signum ( self ) -> Self ;
78
77
79
78
fn mul_add ( self , a : Self , b : Self ) -> Self ;
80
79
@@ -178,6 +177,15 @@ impl F32Ext for f32 {
178
177
fabsf ( self )
179
178
}
180
179
180
+ #[ inline]
181
+ fn signum ( self ) -> Self {
182
+ if self . is_nan ( ) {
183
+ f32:: NAN
184
+ } else {
185
+ copysignf ( 1. , self )
186
+ }
187
+ }
188
+
181
189
#[ inline]
182
190
fn mul_add ( self , a : Self , b : Self ) -> Self {
183
191
fmaf ( self , a, b)
@@ -361,8 +369,7 @@ pub trait F64Ext: private::Sealed + Sized {
361
369
362
370
fn abs ( self ) -> Self ;
363
371
364
- // NOTE depends on unstable intrinsics::copysignf64
365
- // fn signum(self) -> Self;
372
+ fn signum ( self ) -> Self ;
366
373
367
374
fn mul_add ( self , a : Self , b : Self ) -> Self ;
368
375
@@ -466,6 +473,15 @@ impl F64Ext for f64 {
466
473
fabs ( self )
467
474
}
468
475
476
+ #[ inline]
477
+ fn signum ( self ) -> Self {
478
+ if self . is_nan ( ) {
479
+ f64:: NAN
480
+ } else {
481
+ copysign ( 1. , self )
482
+ }
483
+ }
484
+
469
485
#[ inline]
470
486
fn mul_add ( self , a : Self , b : Self ) -> Self {
471
487
fma ( self , a, b)
You can’t perform that action at this time.
0 commit comments