43 lines
26 KiB
Markdown
43 lines
26 KiB
Markdown
---
|
|
title: "rem"
|
|
excerpt: "Compute the remainder after dividing `num` by `div`."
|
|
layout: manual
|
|
---
|
|
|
|
Compute the remainder after dividing `num` by `div`.
|
|
|
|
If `num` is negative, the result will be too.
|
|
|
|
```js
|
|
rem(num: i64, divisor: i64) -> i64
|
|
```
|
|
|
|
### Tags
|
|
|
|
* `math`
|
|
|
|
|
|
### Arguments
|
|
|
|
| Name | Type | Description | Required |
|
|
|----------|------|-------------|----------|
|
|
| `num` | `i64` | | Yes |
|
|
| `divisor` | `i64` | | Yes |
|
|
|
|
### Returns
|
|
|
|
`i64`
|
|
|
|
|
|
### Examples
|
|
|
|
```js
|
|
assertEqual(rem(7, 4), 3, 0.01, "remainder is 3")
|
|
assertEqual(rem(-7, 4), -3, 0.01, "remainder is 3")
|
|
assertEqual(rem(7, -4), 3, 0.01, "remainder is 3")
|
|
```
|
|
|
|

|
|
|
|
|