Part of https://github.com/KittyCAD/modeling-app/issues/4600 Adds support for keyword arguments to the stdlib, and calling stdlib functions with keyword arguments. So far, I've changed one function: `rem`. Previously you would have used `rem(7, 2)` but now it's `rem(7, divisor: 2)`. This is a proof-of-concept. If it's approved, we will: 1. Support closures with keyword arguments, and calling them 2. Move the rest of the stdlib to use kw arguments
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, divisor: 4), 3, 0.01, "remainder is 3")
|
|
assertEqual(rem(-7, divisor: 4), -3, 0.01, "remainder is 3")
|
|
assertEqual(rem(7, divisor: -4), 3, 0.01, "remainder is 3")
|
|
```
|
|
|
|

|
|
|
|
|