Opis

Opis is an arithmetic library for integer numbers.

Author

Roy R. O. Okello

Email

Github

Twitter

Usage

Cargo.toml

text [dependencies] opis = "4.1.0"

Module.rs

text use opis::{ Bit, Int };

API

Bit

```

add: a + b

and: a & b

eq: a == a

not: !a

or: a | b

xor: a ^ b

```

Int

```

addition: a + b, a += b

and: a & b

base2: Int::frombin("1010101"), a.tobin()

base10: Int::fromdec("674755"), a.todec()

base16: Int::fromhex("00ABC012"), a.tohex()

bytes: Int::from(&bytes), a.into()

extended bits: a.toextbits(256)

extended bytes: a.toextbytes(32)

comparision: a < b, a <= b, a > b, a >= b

division: a / b

equivalence: a == b

linear feedback shift register: a.lfsr(1)?

modulo: a.modulo(&m)

multiply: a * b, a *= b

negate: a.negate()

not: !a

or: a | b

exponentiation: a.pow(e)

remainder: a % b

shift left: a << 1, a <<= 1

shift right: a >> 1, a >>= 1

subtraction: a - b, a -= b

```

Twitter

2022-10-18