This repository was archived by the owner on Apr 28, 2025. It is now read-only.
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 {
7373
7474 fn abs ( self ) -> Self ;
7575
76- // NOTE depends on unstable intrinsics::copysignf32
77- // fn signum(self) -> Self;
76+ fn signum ( self ) -> Self ;
7877
7978 fn mul_add ( self , a : Self , b : Self ) -> Self ;
8079
@@ -178,6 +177,15 @@ impl F32Ext for f32 {
178177 fabsf ( self )
179178 }
180179
180+ #[ inline]
181+ fn signum ( self ) -> Self {
182+ if self . is_nan ( ) {
183+ f32:: NAN
184+ } else {
185+ copysignf ( 1. , self )
186+ }
187+ }
188+
181189 #[ inline]
182190 fn mul_add ( self , a : Self , b : Self ) -> Self {
183191 fmaf ( self , a, b)
@@ -361,8 +369,7 @@ pub trait F64Ext: private::Sealed + Sized {
361369
362370 fn abs ( self ) -> Self ;
363371
364- // NOTE depends on unstable intrinsics::copysignf64
365- // fn signum(self) -> Self;
372+ fn signum ( self ) -> Self ;
366373
367374 fn mul_add ( self , a : Self , b : Self ) -> Self ;
368375
@@ -466,6 +473,15 @@ impl F64Ext for f64 {
466473 fabs ( self )
467474 }
468475
476+ #[ inline]
477+ fn signum ( self ) -> Self {
478+ if self . is_nan ( ) {
479+ f64:: NAN
480+ } else {
481+ copysign ( 1. , self )
482+ }
483+ }
484+
469485 #[ inline]
470486 fn mul_add ( self , a : Self , b : Self ) -> Self {
471487 fma ( self , a, b)
You can’t perform that action at this time.
0 commit comments