@@ -45,13 +45,10 @@ fn print_factors_str(
4545 }
4646 // use num_prime's factorize128 algorithm for u128 integers
4747 else if x <= BigUint :: from_u128 ( u128:: MAX ) . unwrap ( ) {
48- let rx = num_str. trim ( ) . parse :: < u128 > ( ) ;
49- let Ok ( x) = rx else {
50- // return Ok(). it's non-fatal and we should try the next number.
51- show_warning ! ( "{}: {}" , num_str. maybe_quote( ) , rx. unwrap_err( ) ) ;
52- set_exit_code ( 1 ) ;
53- return Ok ( ( ) ) ;
54- } ;
48+ // if it's a u128 integer, BigUint will have two u64 digits
49+ // in its Vec<u64>, which index 0 is treated as u64::MAX
50+ let big_uint_u64s = x. clone ( ) . to_u64_digits ( ) ;
51+ let x = u64:: MAX as u128 + big_uint_u64s[ 1 ] as u128 ;
5552 let prime_factors = num_prime:: nt_funcs:: factorize128 ( x) ;
5653 write_result_u128 ( w, & x, prime_factors, print_exponents)
5754 . map_err_context ( || translate ! ( "factor-error-write-error" ) ) ?;
@@ -65,12 +62,12 @@ fn print_factors_str(
6562 translate ! ( "factor-error-factorization-incomplete" ) ,
6663 ) ) ;
6764 }
68- write_result_biguint ( w, & x, prime_factors, print_exponents)
65+ write_result_big_uint ( w, & x, prime_factors, print_exponents)
6966 . map_err_context ( || translate ! ( "factor-error-write-error" ) ) ?;
7067 }
7168 } else {
7269 let empty_primes: BTreeMap < BigUint , usize > = BTreeMap :: new ( ) ;
73- write_result_biguint ( w, & x, empty_primes, print_exponents)
70+ write_result_big_uint ( w, & x, empty_primes, print_exponents)
7471 . map_err_context ( || translate ! ( "factor-error-write-error" ) ) ?;
7572 }
7673
@@ -124,7 +121,7 @@ fn write_result_u128(
124121}
125122
126123/// Writing out the prime factors for BigUint integers
127- fn write_result_biguint (
124+ fn write_result_big_uint (
128125 w : & mut io:: BufWriter < impl Write > ,
129126 x : & BigUint ,
130127 factorization : BTreeMap < BigUint , usize > ,
0 commit comments