File tree 3 files changed +24
-1
lines changed
3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -716,6 +716,7 @@ macro_rules! impl_float {
716
716
}
717
717
}
718
718
719
+ #[ cfg( feature = "std" ) ]
719
720
impl Signum for $ty {
720
721
#[ inline]
721
722
fn signum( self ) -> Self {
Original file line number Diff line number Diff line change @@ -253,3 +253,25 @@ impl MulAdd for f64 {
253
253
:: libm:: fma ( self , m, a)
254
254
}
255
255
}
256
+
257
+ impl Signum for f32 {
258
+ #[ inline]
259
+ fn signum ( self ) -> Self {
260
+ if self . is_nan ( ) {
261
+ Self :: NAN
262
+ } else {
263
+ :: libm:: copysignf ( 1.0 , self )
264
+ }
265
+ }
266
+ }
267
+
268
+ impl Signum for f64 {
269
+ #[ inline]
270
+ fn signum ( self ) -> Self {
271
+ if self . is_nan ( ) {
272
+ Self :: NAN
273
+ } else {
274
+ :: libm:: copysign ( 1.0 , self )
275
+ }
276
+ }
277
+ }
Original file line number Diff line number Diff line change @@ -302,7 +302,7 @@ macro_rules! impl_wide_float {
302
302
impl Signum for $ty {
303
303
#[ inline]
304
304
fn signum( self ) -> Self {
305
- $ ty:: copysign( self , Self :: from( 1.0 ) )
305
+ self . is_nan ( ) . blend ( Self :: from ( $scalar :: NAN ) , $ ty:: copysign( Self :: from( 1.0 ) , self ) )
306
306
}
307
307
}
308
308
) +
You can’t perform that action at this time.
0 commit comments