File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11use num_bigint:: { BigInt , ToBigInt } ;
22use num_traits:: { Float , Signed , ToPrimitive , Zero } ;
33
4+ ///
45pub fn ufrexp ( value : f64 ) -> ( f64 , i32 ) {
56 if 0.0 == value {
67 ( 0.0 , 0i32 )
@@ -12,6 +13,22 @@ pub fn ufrexp(value: f64) -> (f64, i32) {
1213 }
1314}
1415
16+ /// Equate an integer to a float.
17+ ///
18+ /// Returns true if and only if, when converted to each others types, both are equal.
19+ ///
20+ /// # Examples
21+ ///
22+ /// ```
23+ /// use num_bigint::BigInt;
24+ /// use rustpython_common::float_ops::eq_int;
25+ /// let a = 1.0f64;
26+ /// let b = BigInt::from(1);
27+ /// let c = 2.0f64;
28+ /// assert!(eq_int(a, &b));
29+ /// assert!(!eq_int(c, &b));
30+ /// ```
31+ ///
1532pub fn eq_int ( value : f64 , other : & BigInt ) -> bool {
1633 if let ( Some ( self_int) , Some ( other_float) ) = ( value. to_bigint ( ) , other. to_f64 ( ) ) {
1734 value == other_float && self_int == * other
You can’t perform that action at this time.
0 commit comments