File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -336,11 +336,13 @@ pub fn approximate_termial_digits_float(k: u32, n: Float) -> Integer {
336336/// Adjusts the output of [`approximate_factorial`], by combining the 10 exponents of the number and the extra exponent.
337337///
338338/// # Panic
339- /// Will panic if `x` is not finite or `x` is non-positive .
339+ /// Will panic if `x` is not finite.
340340pub fn adjust_approximate ( ( x, e) : ( Float , Integer ) ) -> ( Float , Integer ) {
341- assert ! ( x > 0.0 , "Got non-positive number, x was {x}" ) ;
342341 let prec = x. prec ( ) ;
343- let ( extra, _) = ( x. clone ( ) . ln ( ) / Float :: with_val ( prec, 10 ) . ln ( ) )
342+ if x == 0.0 {
343+ return ( Float :: with_val ( prec, 0 ) , Integer :: ZERO . clone ( ) ) ;
344+ }
345+ let ( extra, _) = ( x. clone ( ) . abs ( ) . ln ( ) / Float :: with_val ( prec, 10 ) . ln ( ) )
344346 . to_integer_round ( rug:: float:: Round :: Down )
345347 . unwrap_or_else ( || panic ! ( "Got non-finite number, x was {x}" ) ) ;
346348 let x = x / ( Float :: with_val ( prec, 10 ) . pow ( extra. clone ( ) ) ) ;
You can’t perform that action at this time.
0 commit comments