* updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * start of types docs Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * add types files Signed-off-by: Jess Frazelle <github@jessfraz.com> * add links Signed-off-by: Jess Frazelle <github@jessfraz.com> * better Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * uodates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
49 lines
118 KiB
Markdown
49 lines
118 KiB
Markdown
---
|
|
title: "int"
|
|
excerpt: "Convert a number to an integer."
|
|
layout: manual
|
|
---
|
|
|
|
Convert a number to an integer.
|
|
|
|
Callers should use floor(), ceil(), or other rounding function first if they care about how numbers with fractional parts are converted. If the number has a fractional part, it's truncated, moving the number towards zero.
|
|
If the number is NaN or has a magnitude, either positive or negative, that is too large to fit into the internal integer representation, the result is a runtime error.
|
|
|
|
```js
|
|
int(num: number) -> i64
|
|
```
|
|
|
|
### Tags
|
|
|
|
* `convert`
|
|
|
|
|
|
### Arguments
|
|
|
|
| Name | Type | Description | Required |
|
|
|----------|------|-------------|----------|
|
|
| `num` | `number` | | Yes |
|
|
|
|
### Returns
|
|
|
|
`i64`
|
|
|
|
|
|
### Examples
|
|
|
|
```js
|
|
let n = int(ceil(5 / 2))
|
|
assertEqual(n, 3, 0.0001, "5/2 = 2.5, rounded up makes 3")
|
|
// Draw n cylinders.
|
|
startSketchOn('XZ')
|
|
|> circle({ center: [0, 0], radius: 2 }, %)
|
|
|> extrude(5, %)
|
|
|> patternTransform(n, (id) => {
|
|
return { translate: [4 * id, 0, 0] }
|
|
}, %)
|
|
```
|
|
|
|

|
|
|
|
|