3 releases
0.1.2 | Jun 26, 2023 |
---|---|
0.1.1 | Jun 2, 2023 |
0.1.0 | May 29, 2023 |
#1691 in Development tools
29 downloads per month
31KB
505 lines
Trait and Functions for efficient development and Computing large numbers
Examples
use libnum::Numeric;
fn main() {
// Computing large number of addition, subtraction, multiplication, and division
let a = "1515454551515151411651651515151665959595956262626265655555599999999999555555555552222222222666666666666663333".to_string();
let b = "9898989898989898989898989898978787979979797979797979797979797979".to_string();
println!("{}", a.add(b.clone()).unwrap());
div
let c = "15454545151513193895151.4215".to_string();
let d = "1545151514151515.313".to_string();
println!("{}", c.div(d.clone()).unwrap());
mul
let c = "15454545151513193895151.4215".to_string();
let d = "1545151514151515.313".to_string();
println!("{}", c.mul(d.clone()).unwrap());
sub
let c = "15454545151513193895151.4215".to_string();
let d = "1545151514151515.313".to_string();
println!("{}", c.sub(d.clone()).unwrap());
add
let c = "15454545151513193895151.4215".to_string();
let d = "1545151514151515.313".to_string();
println!("{}", c.add(d.clone()).unwrap());
xor operation
let c = "15454545151513193895151".to_string();
let d = "15".to_string();
println!("{}", c.xor_operation(d.clone()).unwrap());
or operation
let c = "15454545151513193895151".to_string();
let d = "15".to_string();
println!("{}", c.or_operation(d.clone()).unwrap());
and operation
let c = "15454545151513193895151".to_string();
let d = "15".to_string();
println!("{}", c.and_operation(d.clone()).unwrap());
left shift operation
let c = "15454545151513193895151".to_string();
let d = 15;
println!("{}", c.right_shift(d).unwrap());
left shift operation
let c = "15454545151513193895151".to_string();
let d = 15;
println!("{}", c.left_shift(d).unwrap());
and operation
let c = "15454545151513193895151.4215".to_string();
let d = "15.313".to_string();
println!("{}", c.mod_operation(d.clone()).unwrap());
log
let c = "15454545151513193895151.4215".to_string();
let d = "15.313".to_string();
println!("{}", c.log(d.clone()).unwrap());
atan
let c = "15454545151513193895151.4215".to_string();
println!("{}", c.atan().unwrap());
acos
let c = "15454545151513193895151.4215".to_string();
println!("{}", c.acos().unwrap());
asin
let c = "15454545151513193895151.4215".to_string();
println!("{}", c.asin().unwrap());
tan
let c = "15454545151513193895151.4215".to_string();
println!("{}", c.tan().unwrap());
cos
let c = "15454545151513193895151.4215".to_string();
println!("{}", c.cos().unwrap());
sin
let c = "15454545151513193895151.4215".to_string();
println!("{}", c.sin().unwrap());
log10
let c = "15454545151513193895151.4215".to_string();
println!("{}", c.log10().unwrap());
log2
let c = "15454545151513193895151.4215".to_string();
println!("{}", c.log2().unwrap());
exp
let c = "15454545151513193895151.4215".to_string();
println!("{}", c.exp().unwrap());
sqrt
let c = "15454545151513193895151.4215".to_string();
println!("{}", c.sqrt().unwrap());
pow
let c = "15454545151513193895151.4215".to_string();
let d = "1545151514151515.313".to_string();
println!("{}", c.pow(d.clone()).unwrap());
Dependencies
~6MB
~199K SLoC