@@ -18,12 +18,14 @@ use prelude::v1::*;
1818
1919use intrinsics;
2020use libc:: c_int;
21- use num:: { Float , FloatMath } ;
21+ use num:: { Float , FpCategory } ;
2222use num:: strconv;
2323use num:: strconv:: ExponentFormat :: { ExpNone , ExpDec } ;
2424use num:: strconv:: SignificantDigits :: { DigAll , DigMax , DigExact } ;
2525use num:: strconv:: SignFormat :: SignNeg ;
2626
27+ use core:: num;
28+
2729pub use core:: f64:: { RADIX , MANTISSA_DIGITS , DIGITS , EPSILON , MIN_VALUE } ;
2830pub use core:: f64:: { MIN_POS_VALUE , MAX_VALUE , MIN_EXP , MAX_EXP , MIN_10_EXP } ;
2931pub use core:: f64:: { MAX_10_EXP , NAN , INFINITY , NEG_INFINITY } ;
@@ -80,9 +82,122 @@ mod cmath {
8082}
8183
8284#[ unstable = "trait is unstable" ]
83- impl FloatMath for f64 {
84- /// Constructs a floating point number by multiplying `x` by 2 raised to the
85- /// power of `exp`
85+ impl Float for f64 {
86+ // inlined methods from `num::Float`
87+ #[ inline]
88+ fn nan ( ) -> f64 { num:: Float :: nan ( ) }
89+ #[ inline]
90+ fn infinity ( ) -> f64 { num:: Float :: infinity ( ) }
91+ #[ inline]
92+ fn neg_infinity ( ) -> f64 { num:: Float :: neg_infinity ( ) }
93+ #[ inline]
94+ fn zero ( ) -> f64 { num:: Float :: zero ( ) }
95+ #[ inline]
96+ fn neg_zero ( ) -> f64 { num:: Float :: neg_zero ( ) }
97+ #[ inline]
98+ fn one ( ) -> f64 { num:: Float :: one ( ) }
99+
100+
101+ #[ allow( deprecated) ]
102+ #[ inline]
103+ fn mantissa_digits ( unused_self : Option < f64 > ) -> uint {
104+ num:: Float :: mantissa_digits ( unused_self)
105+ }
106+ #[ allow( deprecated) ]
107+ #[ inline]
108+ fn digits ( unused_self : Option < f64 > ) -> uint { num:: Float :: digits ( unused_self) }
109+ #[ allow( deprecated) ]
110+ #[ inline]
111+ fn epsilon ( ) -> f64 { num:: Float :: epsilon ( ) }
112+ #[ allow( deprecated) ]
113+ #[ inline]
114+ fn min_exp ( unused_self : Option < f64 > ) -> int { num:: Float :: min_exp ( unused_self) }
115+ #[ allow( deprecated) ]
116+ #[ inline]
117+ fn max_exp ( unused_self : Option < f64 > ) -> int { num:: Float :: max_exp ( unused_self) }
118+ #[ allow( deprecated) ]
119+ #[ inline]
120+ fn min_10_exp ( unused_self : Option < f64 > ) -> int { num:: Float :: min_10_exp ( unused_self) }
121+ #[ allow( deprecated) ]
122+ #[ inline]
123+ fn max_10_exp ( unused_self : Option < f64 > ) -> int { num:: Float :: max_10_exp ( unused_self) }
124+ #[ allow( deprecated) ]
125+ #[ inline]
126+ fn min_value ( ) -> f64 { num:: Float :: min_value ( ) }
127+ #[ allow( deprecated) ]
128+ #[ inline]
129+ fn min_pos_value ( unused_self : Option < f64 > ) -> f64 { num:: Float :: min_pos_value ( unused_self) }
130+ #[ allow( deprecated) ]
131+ #[ inline]
132+ fn max_value ( ) -> f64 { num:: Float :: max_value ( ) }
133+
134+ #[ inline]
135+ fn is_nan ( self ) -> bool { num:: Float :: is_nan ( self ) }
136+ #[ inline]
137+ fn is_infinite ( self ) -> bool { num:: Float :: is_infinite ( self ) }
138+ #[ inline]
139+ fn is_finite ( self ) -> bool { num:: Float :: is_finite ( self ) }
140+ #[ inline]
141+ fn is_normal ( self ) -> bool { num:: Float :: is_normal ( self ) }
142+ #[ inline]
143+ fn classify ( self ) -> FpCategory { num:: Float :: classify ( self ) }
144+
145+ #[ inline]
146+ fn integer_decode ( self ) -> ( u64 , i16 , i8 ) { num:: Float :: integer_decode ( self ) }
147+
148+ #[ inline]
149+ fn floor ( self ) -> f64 { num:: Float :: floor ( self ) }
150+ #[ inline]
151+ fn ceil ( self ) -> f64 { num:: Float :: ceil ( self ) }
152+ #[ inline]
153+ fn round ( self ) -> f64 { num:: Float :: round ( self ) }
154+ #[ inline]
155+ fn trunc ( self ) -> f64 { num:: Float :: trunc ( self ) }
156+ #[ inline]
157+ fn fract ( self ) -> f64 { num:: Float :: fract ( self ) }
158+
159+ #[ inline]
160+ fn abs ( self ) -> f64 { num:: Float :: abs ( self ) }
161+ #[ inline]
162+ fn signum ( self ) -> f64 { num:: Float :: signum ( self ) }
163+ #[ inline]
164+ fn is_positive ( self ) -> bool { num:: Float :: is_positive ( self ) }
165+ #[ inline]
166+ fn is_negative ( self ) -> bool { num:: Float :: is_negative ( self ) }
167+
168+ #[ inline]
169+ fn mul_add ( self , a : f64 , b : f64 ) -> f64 { num:: Float :: mul_add ( self , a, b) }
170+ #[ inline]
171+ fn recip ( self ) -> f64 { num:: Float :: recip ( self ) }
172+
173+ #[ inline]
174+ fn powi ( self , n : i32 ) -> f64 { num:: Float :: powi ( self , n) }
175+ #[ inline]
176+ fn powf ( self , n : f64 ) -> f64 { num:: Float :: powf ( self , n) }
177+
178+ #[ inline]
179+ fn sqrt ( self ) -> f64 { num:: Float :: sqrt ( self ) }
180+ #[ inline]
181+ fn rsqrt ( self ) -> f64 { num:: Float :: rsqrt ( self ) }
182+
183+ #[ inline]
184+ fn exp ( self ) -> f64 { num:: Float :: exp ( self ) }
185+ #[ inline]
186+ fn exp2 ( self ) -> f64 { num:: Float :: exp ( self ) }
187+ #[ inline]
188+ fn ln ( self ) -> f64 { num:: Float :: ln ( self ) }
189+ #[ inline]
190+ fn log ( self , base : f64 ) -> f64 { num:: Float :: log ( self , base) }
191+ #[ inline]
192+ fn log2 ( self ) -> f64 { num:: Float :: log2 ( self ) }
193+ #[ inline]
194+ fn log10 ( self ) -> f64 { num:: Float :: log10 ( self ) }
195+
196+ #[ inline]
197+ fn to_degrees ( self ) -> f64 { num:: Float :: to_degrees ( self ) }
198+ #[ inline]
199+ fn to_radians ( self ) -> f64 { num:: Float :: to_radians ( self ) }
200+
86201 #[ inline]
87202 fn ldexp ( x : f64 , exp : int ) -> f64 {
88203 unsafe { cmath:: ldexp ( x, exp as c_int ) }
@@ -640,18 +755,18 @@ mod tests {
640755 // are supported in floating-point literals
641756 let f1: f64 = FromStrRadix :: from_str_radix ( "1p-123" , 16 ) . unwrap ( ) ;
642757 let f2: f64 = FromStrRadix :: from_str_radix ( "1p-111" , 16 ) . unwrap ( ) ;
643- assert_eq ! ( FloatMath :: ldexp( 1f64 , -123 ) , f1) ;
644- assert_eq ! ( FloatMath :: ldexp( 1f64 , -111 ) , f2) ;
758+ assert_eq ! ( Float :: ldexp( 1f64 , -123 ) , f1) ;
759+ assert_eq ! ( Float :: ldexp( 1f64 , -111 ) , f2) ;
645760
646- assert_eq ! ( FloatMath :: ldexp( 0f64 , -123 ) , 0f64 ) ;
647- assert_eq ! ( FloatMath :: ldexp( -0f64 , -123 ) , -0f64 ) ;
761+ assert_eq ! ( Float :: ldexp( 0f64 , -123 ) , 0f64 ) ;
762+ assert_eq ! ( Float :: ldexp( -0f64 , -123 ) , -0f64 ) ;
648763
649764 let inf: f64 = Float :: infinity ( ) ;
650765 let neg_inf: f64 = Float :: neg_infinity ( ) ;
651766 let nan: f64 = Float :: nan ( ) ;
652- assert_eq ! ( FloatMath :: ldexp( inf, -123 ) , inf) ;
653- assert_eq ! ( FloatMath :: ldexp( neg_inf, -123 ) , neg_inf) ;
654- assert ! ( FloatMath :: ldexp( nan, -123 ) . is_nan( ) ) ;
767+ assert_eq ! ( Float :: ldexp( inf, -123 ) , inf) ;
768+ assert_eq ! ( Float :: ldexp( neg_inf, -123 ) , neg_inf) ;
769+ assert ! ( Float :: ldexp( nan, -123 ) . is_nan( ) ) ;
655770 }
656771
657772 #[ test]
@@ -664,8 +779,8 @@ mod tests {
664779 let ( x2, exp2) = f2. frexp ( ) ;
665780 assert_eq ! ( ( x1, exp1) , ( 0.5f64 , -122 ) ) ;
666781 assert_eq ! ( ( x2, exp2) , ( 0.5f64 , -110 ) ) ;
667- assert_eq ! ( FloatMath :: ldexp( x1, exp1) , f1) ;
668- assert_eq ! ( FloatMath :: ldexp( x2, exp2) , f2) ;
782+ assert_eq ! ( Float :: ldexp( x1, exp1) , f1) ;
783+ assert_eq ! ( Float :: ldexp( x2, exp2) , f2) ;
669784
670785 assert_eq ! ( 0f64 . frexp( ) , ( 0f64 , 0 ) ) ;
671786 assert_eq ! ( ( -0f64 ) . frexp( ) , ( -0f64 , 0 ) ) ;
0 commit comments