@@ -784,66 +784,36 @@ impl FloatCore for f32 {
784784 integer_decode_f32 ( self )
785785 }
786786
787- #[ inline]
788- #[ cfg( not( feature = "std" ) ) ]
789- fn classify ( self ) -> FpCategory {
790- const EXP_MASK : u32 = 0x7f800000 ;
791- const MAN_MASK : u32 = 0x007fffff ;
792-
793- let bits: u32 = self . to_bits ( ) ;
794- match ( bits & MAN_MASK , bits & EXP_MASK ) {
795- ( 0 , 0 ) => FpCategory :: Zero ,
796- ( _, 0 ) => FpCategory :: Subnormal ,
797- ( 0 , EXP_MASK ) => FpCategory :: Infinite ,
798- ( _, EXP_MASK ) => FpCategory :: Nan ,
799- _ => FpCategory :: Normal ,
800- }
801- }
802-
803- #[ inline]
804- #[ cfg( not( feature = "std" ) ) ]
805- fn is_sign_negative ( self ) -> bool {
806- const SIGN_MASK : u32 = 0x80000000 ;
807-
808- self . to_bits ( ) & SIGN_MASK != 0
809- }
810-
811- #[ inline]
812- #[ cfg( not( feature = "std" ) ) ]
813- fn to_degrees ( self ) -> Self {
814- // Use a constant for better precision.
815- const PIS_IN_180 : f32 = 57.2957795130823208767981548141051703_f32 ;
816- self * PIS_IN_180
817- }
818-
819- #[ inline]
820- #[ cfg( not( feature = "std" ) ) ]
821- fn to_radians ( self ) -> Self {
822- self * ( f32:: consts:: PI / 180.0 )
823- }
824-
825- #[ cfg( feature = "std" ) ]
826787 forward ! {
827788 Self :: is_nan( self ) -> bool ;
828789 Self :: is_infinite( self ) -> bool ;
829790 Self :: is_finite( self ) -> bool ;
830791 Self :: is_normal( self ) -> bool ;
831792 Self :: classify( self ) -> FpCategory ;
793+ Self :: is_sign_positive( self ) -> bool ;
794+ Self :: is_sign_negative( self ) -> bool ;
795+ Self :: min( self , other: Self ) -> Self ;
796+ Self :: max( self , other: Self ) -> Self ;
797+ Self :: recip( self ) -> Self ;
798+ Self :: to_degrees( self ) -> Self ;
799+ Self :: to_radians( self ) -> Self ;
800+ }
801+
802+ #[ cfg( has_is_subnormal) ]
803+ forward ! {
804+ Self :: is_subnormal( self ) -> bool ;
805+ }
806+
807+ #[ cfg( feature = "std" ) ]
808+ forward ! {
832809 Self :: floor( self ) -> Self ;
833810 Self :: ceil( self ) -> Self ;
834811 Self :: round( self ) -> Self ;
835812 Self :: trunc( self ) -> Self ;
836813 Self :: fract( self ) -> Self ;
837814 Self :: abs( self ) -> Self ;
838815 Self :: signum( self ) -> Self ;
839- Self :: is_sign_positive( self ) -> bool ;
840- Self :: is_sign_negative( self ) -> bool ;
841- Self :: min( self , other: Self ) -> Self ;
842- Self :: max( self , other: Self ) -> Self ;
843- Self :: recip( self ) -> Self ;
844816 Self :: powi( self , n: i32 ) -> Self ;
845- Self :: to_degrees( self ) -> Self ;
846- Self :: to_radians( self ) -> Self ;
847817 }
848818
849819 #[ cfg( all( not( feature = "std" ) , feature = "libm" ) ) ]
@@ -853,8 +823,6 @@ impl FloatCore for f32 {
853823 libm:: roundf as round( self ) -> Self ;
854824 libm:: truncf as trunc( self ) -> Self ;
855825 libm:: fabsf as abs( self ) -> Self ;
856- libm:: fminf as min( self , other: Self ) -> Self ;
857- libm:: fmaxf as max( self , other: Self ) -> Self ;
858826 }
859827
860828 #[ cfg( all( not( feature = "std" ) , feature = "libm" ) ) ]
@@ -881,65 +849,17 @@ impl FloatCore for f64 {
881849 integer_decode_f64 ( self )
882850 }
883851
884- #[ inline]
885- #[ cfg( not( feature = "std" ) ) ]
886- fn classify ( self ) -> FpCategory {
887- const EXP_MASK : u64 = 0x7ff0000000000000 ;
888- const MAN_MASK : u64 = 0x000fffffffffffff ;
889-
890- let bits: u64 = self . to_bits ( ) ;
891- match ( bits & MAN_MASK , bits & EXP_MASK ) {
892- ( 0 , 0 ) => FpCategory :: Zero ,
893- ( _, 0 ) => FpCategory :: Subnormal ,
894- ( 0 , EXP_MASK ) => FpCategory :: Infinite ,
895- ( _, EXP_MASK ) => FpCategory :: Nan ,
896- _ => FpCategory :: Normal ,
897- }
898- }
899-
900- #[ inline]
901- #[ cfg( not( feature = "std" ) ) ]
902- fn is_sign_negative ( self ) -> bool {
903- const SIGN_MASK : u64 = 0x8000000000000000 ;
904-
905- self . to_bits ( ) & SIGN_MASK != 0
906- }
907-
908- #[ inline]
909- #[ cfg( not( feature = "std" ) ) ]
910- fn to_degrees ( self ) -> Self {
911- // The division here is correctly rounded with respect to the true
912- // value of 180/π. (This differs from f32, where a constant must be
913- // used to ensure a correctly rounded result.)
914- self * ( 180.0 / f64:: consts:: PI )
915- }
916-
917- #[ inline]
918- #[ cfg( not( feature = "std" ) ) ]
919- fn to_radians ( self ) -> Self {
920- self * ( f64:: consts:: PI / 180.0 )
921- }
922-
923- #[ cfg( feature = "std" ) ]
924852 forward ! {
925853 Self :: is_nan( self ) -> bool ;
926854 Self :: is_infinite( self ) -> bool ;
927855 Self :: is_finite( self ) -> bool ;
928856 Self :: is_normal( self ) -> bool ;
929857 Self :: classify( self ) -> FpCategory ;
930- Self :: floor( self ) -> Self ;
931- Self :: ceil( self ) -> Self ;
932- Self :: round( self ) -> Self ;
933- Self :: trunc( self ) -> Self ;
934- Self :: fract( self ) -> Self ;
935- Self :: abs( self ) -> Self ;
936- Self :: signum( self ) -> Self ;
937858 Self :: is_sign_positive( self ) -> bool ;
938859 Self :: is_sign_negative( self ) -> bool ;
939860 Self :: min( self , other: Self ) -> Self ;
940861 Self :: max( self , other: Self ) -> Self ;
941862 Self :: recip( self ) -> Self ;
942- Self :: powi( self , n: i32 ) -> Self ;
943863 Self :: to_degrees( self ) -> Self ;
944864 Self :: to_radians( self ) -> Self ;
945865 }
@@ -949,15 +869,25 @@ impl FloatCore for f64 {
949869 Self :: is_subnormal( self ) -> bool ;
950870 }
951871
872+ #[ cfg( feature = "std" ) ]
873+ forward ! {
874+ Self :: floor( self ) -> Self ;
875+ Self :: ceil( self ) -> Self ;
876+ Self :: round( self ) -> Self ;
877+ Self :: trunc( self ) -> Self ;
878+ Self :: fract( self ) -> Self ;
879+ Self :: abs( self ) -> Self ;
880+ Self :: signum( self ) -> Self ;
881+ Self :: powi( self , n: i32 ) -> Self ;
882+ }
883+
952884 #[ cfg( all( not( feature = "std" ) , feature = "libm" ) ) ]
953885 forward ! {
954886 libm:: floor as floor( self ) -> Self ;
955887 libm:: ceil as ceil( self ) -> Self ;
956888 libm:: round as round( self ) -> Self ;
957889 libm:: trunc as trunc( self ) -> Self ;
958890 libm:: fabs as abs( self ) -> Self ;
959- libm:: fmin as min( self , other: Self ) -> Self ;
960- libm:: fmax as max( self , other: Self ) -> Self ;
961891 }
962892
963893 #[ cfg( all( not( feature = "std" ) , feature = "libm" ) ) ]
@@ -2058,18 +1988,28 @@ macro_rules! float_impl_libm {
20581988 }
20591989
20601990 forward! {
2061- FloatCore :: is_nan( self ) -> bool ;
2062- FloatCore :: is_infinite( self ) -> bool ;
2063- FloatCore :: is_finite( self ) -> bool ;
2064- FloatCore :: is_normal( self ) -> bool ;
2065- FloatCore :: classify( self ) -> FpCategory ;
1991+ Self :: is_nan( self ) -> bool ;
1992+ Self :: is_infinite( self ) -> bool ;
1993+ Self :: is_finite( self ) -> bool ;
1994+ Self :: is_normal( self ) -> bool ;
1995+ Self :: classify( self ) -> FpCategory ;
1996+ Self :: is_sign_positive( self ) -> bool ;
1997+ Self :: is_sign_negative( self ) -> bool ;
1998+ Self :: min( self , other: Self ) -> Self ;
1999+ Self :: max( self , other: Self ) -> Self ;
2000+ Self :: recip( self ) -> Self ;
2001+ Self :: to_degrees( self ) -> Self ;
2002+ Self :: to_radians( self ) -> Self ;
2003+ }
2004+
2005+ #[ cfg( has_is_subnormal) ]
2006+ forward! {
2007+ Self :: is_subnormal( self ) -> bool ;
2008+ }
2009+
2010+ forward! {
20662011 FloatCore :: signum( self ) -> Self ;
2067- FloatCore :: is_sign_positive( self ) -> bool ;
2068- FloatCore :: is_sign_negative( self ) -> bool ;
2069- FloatCore :: recip( self ) -> Self ;
20702012 FloatCore :: powi( self , n: i32 ) -> Self ;
2071- FloatCore :: to_degrees( self ) -> Self ;
2072- FloatCore :: to_radians( self ) -> Self ;
20732013 }
20742014 } ;
20752015}
@@ -2149,8 +2089,6 @@ impl Float for f32 {
21492089 libm:: asinhf as asinh( self ) -> Self ;
21502090 libm:: acoshf as acosh( self ) -> Self ;
21512091 libm:: atanhf as atanh( self ) -> Self ;
2152- libm:: fmaxf as max( self , other: Self ) -> Self ;
2153- libm:: fminf as min( self , other: Self ) -> Self ;
21542092 libm:: copysignf as copysign( self , other: Self ) -> Self ;
21552093 }
21562094}
@@ -2197,8 +2135,6 @@ impl Float for f64 {
21972135 libm:: asinh as asinh( self ) -> Self ;
21982136 libm:: acosh as acosh( self ) -> Self ;
21992137 libm:: atanh as atanh( self ) -> Self ;
2200- libm:: fmax as max( self , other: Self ) -> Self ;
2201- libm:: fmin as min( self , other: Self ) -> Self ;
22022138 libm:: copysign as copysign( self , sign: Self ) -> Self ;
22032139 }
22042140}
0 commit comments