| Crates.io | big_complex |
| lib.rs | big_complex |
| version | 0.1.0 |
| created_at | 2025-07-19 05:25:06.533251+00 |
| updated_at | 2025-07-19 05:25:06.533251+00 |
| description | A Library for Complicated Arithmetic with Big Complex Numbers |
| homepage | |
| repository | https://github.com/AlanKSorata/big_complex |
| max_upload_size | |
| id | 1759930 |
| size | 84,843 |
A calculation module implemented in Rust language that supports large number complex operations, providing a rich set of mathematical operation functions.
pow)sqrt)gcd)lcm)mod_pow)mod_inv)factorial) - Calculate n!is_prime) - Determine whether it is a prime numbernext_prime) - Find the smallest prime number greater than the current numberbit_length() - Get the binary bit lengthcount_ones() - Calculate the number of 1s in the binarytrailing_zeros() - Calculate the number of trailing zerosis_power_of_two() - Determine whether it is a power of 2next_power_of_two() - Get the next power of 2conjugate)magnitude_squared)scale)pow)magnitude) - Calculate the magnitude of a complex numberfrom_polar) - Create a complex number from polar coordinatesarg_quadrant) - Determine the quadrant where the complex number liesrotate_90() - Rotate counterclockwise by 90 degreesrotate_180() - Rotate by 180 degreesrotate_270() - Rotate counterclockwise by 270 degreesnth_root) - Calculate the nth root of a complex numberln_approx) - Simplified calculation of the natural logarithm of a complex numberexp_approx) - Simplified calculation of the exponential function of a complex numberuse big_complex::{BigInt, BigComplex};
// Large integer operations
let n = BigInt::new(10);
println!("10! = {}", n.factorial().unwrap());
let num = BigInt::new(97);
println!("{} is prime: {}", num, num.is_prime());
// Complex number operations
let z = BigComplex::from_i64(3, 4);
println!("Magnitude: {}", z.magnitude());
println!("Rotated 90°: {}", z.rotate_90());
// Advanced operations
let roots = BigComplex::from_i64(16, 0).nth_root(2);
println!("Square roots: {:?}", roots);
# Run all tests
cargo test
# Run the example program
cargo run --example usage
# Run specific tests
cargo test test_big_int_factorial
cargo test test_big_complex_rotation
src/
├── lib.rs # Module export
├── big_int.rs # Large integer implementation
└── big_complex.rs # Large complex number implementation
tests/
└── integration_tests.rs # Integration tests
examples/
└── usage.rs # Usage example
num-bigint - Underlying implementation of large integersnum-traits - Numerical traitsnum-complex - Complex number supportnum-integer - Integer operationsThis project successfully implements a fully functional large number complex operation calculation module, including:
The implementation of each new function follows the "implement - test" development model to ensure code quality and functional correctness.