Opis is an arithmetic library for integer numbers written in Rust.
In your Cargo.toml
:
```
[dependencies] opis = "1.1.0"
```
In your Rust file:
```
use opis::Int;
```
From Str
:
```
let integer: Int = Int::from_str("6747", 10)?;
```
To Str
:
```
let binarystr: String = integer.tostr(2);
```
Addition
```
let s = inta.add(&int2b);
```
Subtraction
```
let d = inta.sub(&intb).unwrap();
```
Multiplication
```
let p = inta.mul(&intb);
```
Division
```
let q = inta.div(&intb).unwrap();
```
Remainder
```
let r = inta.rem(&intb).unwrap();
```
Modulo
```
let m = inta.modulo(&intb).unwrap();
```
Exponentiation
```
let p = inta.pow(&inte);
```
Modular Inverse
```
let mi = inta.modinv(&int_m);
```
```
let ans1: bool = inta.isgreater(&intb);
let ans2: bool = inta.isless(&intb);
let ans3: bool = inta.isequal(&intb);
```
NOT
```
let n = int_x.not();
```
AND
```
let a = intx.and(&inty);
```
OR
```
let o = intx.or(&inty);
```
XOR
```
let x = intx.xor(&inty);
```
Pull requests, bug reports and any kind of suggestion are welcome.
2021-12-12