pub fn into_integer(self) -> Result<i64, Self> {
        fn float_int(s: &f64) -> Option<i64> {
            if (s.round() - s).abs() <= std::f64::EPSILON {
                Some(s.round() as i64)
            } else {
                None
            }
        }
        match &self.value {
            NumValue::Rational(s) => {
                if s.is_integer() {
                    Ok(s.to_integer())
                } else {
                    float_int(&ratio_to_float(s)).ok_or(self)
                }
            }
            NumValue::BigRational(s) => {
                if s.is_integer() {
                    i64::try_from(s.to_integer()).map_err(|_| self)
                } else {
                    float_int(&ratio_to_float(s)).ok_or(self)
                }
            }
            NumValue::Float(s) => float_int(s).ok_or(self),
        }
    }
/// Returns true if the number is an integer.
Returns true if the number is an integer.
Returns true if the number is an integer .
pub fn into_integer(self) -> Result<i64, Self> {
        fn float_int(s: &f64) -> Option<i64> {
            if (s.round() - s).abs() <= std::f64::EPSILON {
                Some(s.round() as i64)
            } else {
                None
            }
        }
        match &self.value {
            NumValue::Rational(s) => {
                if s.is_integer() {
                    Ok(s.to_integer())
                } else {
                    float_int(&ratio_to_float(s)).ok_or(self)
                }
            }
            NumValue::BigRational(s) => {
                if s.is_integer() {
                    i64::try_from(s.to_integer()).map_err(|_| self)
                } else {
                    float_int(&ratio_to_float(s)).ok_or(self)
                }
            }
            NumValue::Float(s) => float_int(s).ok_or(self),
        }
    }
pub fn into_integer ( self ) -> Result < i64 , Self > { fn float_int ( s : & f64 ) -> Option < i64 > { if ( s . round ( ) - s ) . abs ( ) <= std :: f64 :: EPSILON { Some ( s . round ( ) as i64 ) } else { None } } match & self . value { NumValue :: Rational ( s ) => { if s . is_integer ( ) { Ok ( s . to_integer ( ) ) } else { float_int ( & ratio_to_float ( s ) ) . ok_or ( self ) } } NumValue :: BigRational ( s ) => { if s . is_integer ( ) { i64 :: try_from ( s . to_integer ( ) ) . map_err ( | _ | self ) } else { float_int ( & ratio_to_float ( s ) ) . ok_or ( self ) } } NumValue :: Float ( s ) => float_int ( s ) . ok_or ( self ) , } }
Returns true if the number is an integer.
Returns true if the number is an integer .
self
self