> ## Documentation Index
> Fetch the complete documentation index at: https://docs.starknet.io/llms.txt
> Use this file to discover all available pages before exploring further.

# core::num::traits::ops::divrem::DivRem

Performs truncated division and remainder.
`T` – dividend type (left-hand operand)
`U` – divisor  type (right-hand operand, must be wrapped in
`NonZero` at call-site)
The division truncates toward zero, like Cairo’s `/` and `%`.

## Signature

```rust theme={null}
pub trait DivRem
```

# Associated types

* `Quotient` – the type produced by the division
* `Remainder` – the type produced by the modulo

## Examples

Identical operand types:

```rust theme={null}
use core::traits::{DivRem, NonZero};

let lhs: u32 = 7;
let rhs: NonZero = 3.try_into().unwrap();
assert!(DivRem::::div_rem(lhs, rhs) == (2, 1));
```

Heterogeneous division (`u256` by `u128`):

```rust theme={null}
use core::traits::DivRem;
use integer::u256_as_non_zero;

let big: u256 = 1_000_000;                    // dividend
let nz10: NonZero = u256_as_non_zero(10_u128.into());  // divisor

let (q, r) = DivRem::::div_rem(big, nz10);
// q : u256, r : u128
```

## Trait functions

### div\_rem

Computes both `/` and `%` in a single pass.

#### Signature

```rust theme={null}
fn div_rem(self: T, other: NonZero) -> (DivRemQuotient, DivRemRemainder)
```

## Trait types

### Quotient

Quotient returned by the division.

#### Signature

```rust theme={null}
type Quotient;
```

### Remainder

Remainder returned by the modulo operation.

#### Signature

```rust theme={null}
type Remainder;
```
