# Trait hacspec_lib::prelude::ModNumeric

source · [−]```
pub trait ModNumeric {
fn sub_mod(self, rhs: Self, n: Self) -> Self;
fn add_mod(self, rhs: Self, n: Self) -> Self;
fn mul_mod(self, rhs: Self, n: Self) -> Self;
fn pow_mod(self, exp: Self, n: Self) -> Self;
fn modulo(self, n: Self) -> Self;
fn signed_modulo(self, n: Self) -> Self;
fn absolute(self) -> Self;
}
```

## Required Methods

#### fn signed_modulo(self, n: Self) -> Self

#### fn signed_modulo(self, n: Self) -> Self

`self % n`

that always returns a positive integer

## Implementations on Foreign Types

source### impl ModNumeric for u8

### impl ModNumeric for u8

source#### fn sub_mod(self, rhs: Self, n: Self) -> Self

#### fn sub_mod(self, rhs: Self, n: Self) -> Self

*This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.*
(self - rhs) % n.

source#### fn add_mod(self, rhs: Self, n: Self) -> Self

#### fn add_mod(self, rhs: Self, n: Self) -> Self

*This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.*
`(self + rhs) % n`

source#### fn mul_mod(self, rhs: Self, n: Self) -> Self

#### fn mul_mod(self, rhs: Self, n: Self) -> Self

*This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.*
`(self * rhs) % n`

source#### fn pow_mod(self, _exp: Self, _n: Self) -> Self

#### fn pow_mod(self, _exp: Self, _n: Self) -> Self

`(self ^ exp) % n`

source#### fn modulo(self, n: Self) -> Self

#### fn modulo(self, n: Self) -> Self

`self % n`

source#### fn signed_modulo(self, n: Self) -> Self

#### fn signed_modulo(self, n: Self) -> Self

`self % n`

that always returns a positive integer

source### impl ModNumeric for u16

### impl ModNumeric for u16

source#### fn sub_mod(self, rhs: Self, n: Self) -> Self

#### fn sub_mod(self, rhs: Self, n: Self) -> Self

source#### fn add_mod(self, rhs: Self, n: Self) -> Self

#### fn add_mod(self, rhs: Self, n: Self) -> Self

`(self + rhs) % n`

source#### fn mul_mod(self, rhs: Self, n: Self) -> Self

#### fn mul_mod(self, rhs: Self, n: Self) -> Self

`(self * rhs) % n`

source#### fn pow_mod(self, _exp: Self, _n: Self) -> Self

#### fn pow_mod(self, _exp: Self, _n: Self) -> Self

`(self ^ exp) % n`

source#### fn modulo(self, n: Self) -> Self

#### fn modulo(self, n: Self) -> Self

`self % n`

source#### fn signed_modulo(self, n: Self) -> Self

#### fn signed_modulo(self, n: Self) -> Self

`self % n`

that always returns a positive integer

source### impl ModNumeric for u32

### impl ModNumeric for u32

source#### fn sub_mod(self, rhs: Self, n: Self) -> Self

#### fn sub_mod(self, rhs: Self, n: Self) -> Self

source#### fn add_mod(self, rhs: Self, n: Self) -> Self

#### fn add_mod(self, rhs: Self, n: Self) -> Self

`(self + rhs) % n`

source#### fn mul_mod(self, rhs: Self, n: Self) -> Self

#### fn mul_mod(self, rhs: Self, n: Self) -> Self

`(self * rhs) % n`

source#### fn pow_mod(self, _exp: Self, _n: Self) -> Self

#### fn pow_mod(self, _exp: Self, _n: Self) -> Self

`(self ^ exp) % n`

source#### fn modulo(self, n: Self) -> Self

#### fn modulo(self, n: Self) -> Self

`self % n`

source#### fn signed_modulo(self, n: Self) -> Self

#### fn signed_modulo(self, n: Self) -> Self

`self % n`

that always returns a positive integer

source### impl ModNumeric for u64

### impl ModNumeric for u64

source#### fn sub_mod(self, rhs: Self, n: Self) -> Self

#### fn sub_mod(self, rhs: Self, n: Self) -> Self

source#### fn add_mod(self, rhs: Self, n: Self) -> Self

#### fn add_mod(self, rhs: Self, n: Self) -> Self

`(self + rhs) % n`

source#### fn mul_mod(self, rhs: Self, n: Self) -> Self

#### fn mul_mod(self, rhs: Self, n: Self) -> Self

`(self * rhs) % n`

source#### fn pow_mod(self, _exp: Self, _n: Self) -> Self

#### fn pow_mod(self, _exp: Self, _n: Self) -> Self

`(self ^ exp) % n`

source#### fn modulo(self, n: Self) -> Self

#### fn modulo(self, n: Self) -> Self

`self % n`

source#### fn signed_modulo(self, n: Self) -> Self

#### fn signed_modulo(self, n: Self) -> Self

`self % n`

that always returns a positive integer

source### impl ModNumeric for u128

### impl ModNumeric for u128

source#### fn sub_mod(self, rhs: Self, n: Self) -> Self

#### fn sub_mod(self, rhs: Self, n: Self) -> Self

source#### fn add_mod(self, rhs: Self, n: Self) -> Self

#### fn add_mod(self, rhs: Self, n: Self) -> Self

`(self + rhs) % n`

source#### fn mul_mod(self, rhs: Self, n: Self) -> Self

#### fn mul_mod(self, rhs: Self, n: Self) -> Self

`(self * rhs) % n`

source#### fn pow_mod(self, _exp: Self, _n: Self) -> Self

#### fn pow_mod(self, _exp: Self, _n: Self) -> Self

`(self ^ exp) % n`

source#### fn modulo(self, n: Self) -> Self

#### fn modulo(self, n: Self) -> Self

`self % n`

source#### fn signed_modulo(self, n: Self) -> Self

#### fn signed_modulo(self, n: Self) -> Self

`self % n`

that always returns a positive integer

source### impl ModNumeric for i8

### impl ModNumeric for i8

source#### fn sub_mod(self, rhs: Self, n: Self) -> Self

#### fn sub_mod(self, rhs: Self, n: Self) -> Self

source#### fn add_mod(self, rhs: Self, n: Self) -> Self

#### fn add_mod(self, rhs: Self, n: Self) -> Self

`(self + rhs) % n`

source#### fn mul_mod(self, rhs: Self, n: Self) -> Self

#### fn mul_mod(self, rhs: Self, n: Self) -> Self

`(self * rhs) % n`

source#### fn pow_mod(self, exp: Self, n: Self) -> Self

#### fn pow_mod(self, exp: Self, n: Self) -> Self

*This function can be called from hacspec programs but its body features Rust constructs that are not part of hacspec*
`(self ^ exp) % n`

source#### fn modulo(self, n: Self) -> Self

#### fn modulo(self, n: Self) -> Self

`self % n`

source#### fn signed_modulo(self, n: Self) -> Self

#### fn signed_modulo(self, n: Self) -> Self

`self % n`

that always returns a positive integer

source### impl ModNumeric for i16

### impl ModNumeric for i16

source#### fn sub_mod(self, rhs: Self, n: Self) -> Self

#### fn sub_mod(self, rhs: Self, n: Self) -> Self

source#### fn add_mod(self, rhs: Self, n: Self) -> Self

#### fn add_mod(self, rhs: Self, n: Self) -> Self

`(self + rhs) % n`

source#### fn mul_mod(self, rhs: Self, n: Self) -> Self

#### fn mul_mod(self, rhs: Self, n: Self) -> Self

`(self * rhs) % n`

source#### fn pow_mod(self, exp: Self, n: Self) -> Self

#### fn pow_mod(self, exp: Self, n: Self) -> Self

*This function can be called from hacspec programs but its body features Rust constructs that are not part of hacspec*
`(self ^ exp) % n`

source#### fn modulo(self, n: Self) -> Self

#### fn modulo(self, n: Self) -> Self

`self % n`

source#### fn signed_modulo(self, n: Self) -> Self

#### fn signed_modulo(self, n: Self) -> Self

`self % n`

that always returns a positive integer

source### impl ModNumeric for i32

### impl ModNumeric for i32

source#### fn sub_mod(self, rhs: Self, n: Self) -> Self

#### fn sub_mod(self, rhs: Self, n: Self) -> Self

source#### fn add_mod(self, rhs: Self, n: Self) -> Self

#### fn add_mod(self, rhs: Self, n: Self) -> Self

`(self + rhs) % n`

source#### fn mul_mod(self, rhs: Self, n: Self) -> Self

#### fn mul_mod(self, rhs: Self, n: Self) -> Self

`(self * rhs) % n`

source#### fn pow_mod(self, exp: Self, n: Self) -> Self

#### fn pow_mod(self, exp: Self, n: Self) -> Self

*This function can be called from hacspec programs but its body features Rust constructs that are not part of hacspec*
`(self ^ exp) % n`

source#### fn modulo(self, n: Self) -> Self

#### fn modulo(self, n: Self) -> Self

`self % n`

source#### fn signed_modulo(self, n: Self) -> Self

#### fn signed_modulo(self, n: Self) -> Self

`self % n`

that always returns a positive integer

source### impl ModNumeric for i64

### impl ModNumeric for i64

source#### fn sub_mod(self, rhs: Self, n: Self) -> Self

#### fn sub_mod(self, rhs: Self, n: Self) -> Self

source#### fn add_mod(self, rhs: Self, n: Self) -> Self

#### fn add_mod(self, rhs: Self, n: Self) -> Self

`(self + rhs) % n`

source#### fn mul_mod(self, rhs: Self, n: Self) -> Self

#### fn mul_mod(self, rhs: Self, n: Self) -> Self

`(self * rhs) % n`

source#### fn pow_mod(self, exp: Self, n: Self) -> Self

#### fn pow_mod(self, exp: Self, n: Self) -> Self

`(self ^ exp) % n`

source#### fn modulo(self, n: Self) -> Self

#### fn modulo(self, n: Self) -> Self

`self % n`

source#### fn signed_modulo(self, n: Self) -> Self

#### fn signed_modulo(self, n: Self) -> Self

`self % n`

that always returns a positive integer

source### impl ModNumeric for i128

### impl ModNumeric for i128

source#### fn sub_mod(self, rhs: Self, n: Self) -> Self

#### fn sub_mod(self, rhs: Self, n: Self) -> Self

source#### fn add_mod(self, rhs: Self, n: Self) -> Self

#### fn add_mod(self, rhs: Self, n: Self) -> Self

`(self + rhs) % n`

source#### fn mul_mod(self, rhs: Self, n: Self) -> Self

#### fn mul_mod(self, rhs: Self, n: Self) -> Self

`(self * rhs) % n`

source#### fn pow_mod(self, exp: Self, n: Self) -> Self

#### fn pow_mod(self, exp: Self, n: Self) -> Self

`(self ^ exp) % n`

source#### fn modulo(self, n: Self) -> Self

#### fn modulo(self, n: Self) -> Self

`self % n`

source#### fn signed_modulo(self, n: Self) -> Self

#### fn signed_modulo(self, n: Self) -> Self

`self % n`

that always returns a positive integer