@@ -784,66 +784,36 @@ impl FloatCore for f32 {
784
784
integer_decode_f32 ( self )
785
785
}
786
786
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" ) ]
826
787
forward ! {
827
788
Self :: is_nan( self ) -> bool ;
828
789
Self :: is_infinite( self ) -> bool ;
829
790
Self :: is_finite( self ) -> bool ;
830
791
Self :: is_normal( self ) -> bool ;
831
792
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 ! {
832
809
Self :: floor( self ) -> Self ;
833
810
Self :: ceil( self ) -> Self ;
834
811
Self :: round( self ) -> Self ;
835
812
Self :: trunc( self ) -> Self ;
836
813
Self :: fract( self ) -> Self ;
837
814
Self :: abs( self ) -> Self ;
838
815
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 ;
844
816
Self :: powi( self , n: i32 ) -> Self ;
845
- Self :: to_degrees( self ) -> Self ;
846
- Self :: to_radians( self ) -> Self ;
847
817
}
848
818
849
819
#[ cfg( all( not( feature = "std" ) , feature = "libm" ) ) ]
@@ -853,8 +823,6 @@ impl FloatCore for f32 {
853
823
libm:: roundf as round( self ) -> Self ;
854
824
libm:: truncf as trunc( self ) -> Self ;
855
825
libm:: fabsf as abs( self ) -> Self ;
856
- libm:: fminf as min( self , other: Self ) -> Self ;
857
- libm:: fmaxf as max( self , other: Self ) -> Self ;
858
826
}
859
827
860
828
#[ cfg( all( not( feature = "std" ) , feature = "libm" ) ) ]
@@ -881,65 +849,17 @@ impl FloatCore for f64 {
881
849
integer_decode_f64 ( self )
882
850
}
883
851
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" ) ]
924
852
forward ! {
925
853
Self :: is_nan( self ) -> bool ;
926
854
Self :: is_infinite( self ) -> bool ;
927
855
Self :: is_finite( self ) -> bool ;
928
856
Self :: is_normal( self ) -> bool ;
929
857
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 ;
937
858
Self :: is_sign_positive( self ) -> bool ;
938
859
Self :: is_sign_negative( self ) -> bool ;
939
860
Self :: min( self , other: Self ) -> Self ;
940
861
Self :: max( self , other: Self ) -> Self ;
941
862
Self :: recip( self ) -> Self ;
942
- Self :: powi( self , n: i32 ) -> Self ;
943
863
Self :: to_degrees( self ) -> Self ;
944
864
Self :: to_radians( self ) -> Self ;
945
865
}
@@ -949,15 +869,25 @@ impl FloatCore for f64 {
949
869
Self :: is_subnormal( self ) -> bool ;
950
870
}
951
871
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
+
952
884
#[ cfg( all( not( feature = "std" ) , feature = "libm" ) ) ]
953
885
forward ! {
954
886
libm:: floor as floor( self ) -> Self ;
955
887
libm:: ceil as ceil( self ) -> Self ;
956
888
libm:: round as round( self ) -> Self ;
957
889
libm:: trunc as trunc( self ) -> Self ;
958
890
libm:: fabs as abs( self ) -> Self ;
959
- libm:: fmin as min( self , other: Self ) -> Self ;
960
- libm:: fmax as max( self , other: Self ) -> Self ;
961
891
}
962
892
963
893
#[ cfg( all( not( feature = "std" ) , feature = "libm" ) ) ]
@@ -2058,18 +1988,28 @@ macro_rules! float_impl_libm {
2058
1988
}
2059
1989
2060
1990
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! {
2066
2011
FloatCore :: signum( self ) -> Self ;
2067
- FloatCore :: is_sign_positive( self ) -> bool ;
2068
- FloatCore :: is_sign_negative( self ) -> bool ;
2069
- FloatCore :: recip( self ) -> Self ;
2070
2012
FloatCore :: powi( self , n: i32 ) -> Self ;
2071
- FloatCore :: to_degrees( self ) -> Self ;
2072
- FloatCore :: to_radians( self ) -> Self ;
2073
2013
}
2074
2014
} ;
2075
2015
}
@@ -2149,8 +2089,6 @@ impl Float for f32 {
2149
2089
libm:: asinhf as asinh( self ) -> Self ;
2150
2090
libm:: acoshf as acosh( self ) -> Self ;
2151
2091
libm:: atanhf as atanh( self ) -> Self ;
2152
- libm:: fmaxf as max( self , other: Self ) -> Self ;
2153
- libm:: fminf as min( self , other: Self ) -> Self ;
2154
2092
libm:: copysignf as copysign( self , other: Self ) -> Self ;
2155
2093
}
2156
2094
}
@@ -2197,8 +2135,6 @@ impl Float for f64 {
2197
2135
libm:: asinh as asinh( self ) -> Self ;
2198
2136
libm:: acosh as acosh( self ) -> Self ;
2199
2137
libm:: atanh as atanh( self ) -> Self ;
2200
- libm:: fmax as max( self , other: Self ) -> Self ;
2201
- libm:: fmin as min( self , other: Self ) -> Self ;
2202
2138
libm:: copysign as copysign( self , sign: Self ) -> Self ;
2203
2139
}
2204
2140
}
0 commit comments