Add int() function to KCL stdlib (#3116)

This commit is contained in:
Jonathan Tran
2024-07-25 21:18:52 -04:00
committed by GitHub
parent 029799215b
commit 4dd8a25fdd
8 changed files with 186 additions and 0 deletions

View File

@ -38,6 +38,7 @@ layout: manual
* [`helix`](kcl/helix)
* [`hole`](kcl/hole)
* [`import`](kcl/import)
* [`int`](kcl/int)
* [`lastSegX`](kcl/lastSegX)
* [`lastSegY`](kcl/lastSegY)
* [`legAngX`](kcl/legAngX)

43
docs/kcl/int.md Normal file

File diff suppressed because one or more lines are too long

View File

@ -85702,6 +85702,39 @@
"const model = import(\"tests/inputs/cube.step\")"
]
},
{
"name": "int",
"summary": "Converts a number to an integer.",
"description": "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.\nIf 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.",
"tags": [
"convert"
],
"args": [
{
"name": "num",
"type": "number",
"schema": {
"type": "number",
"format": "double"
},
"required": true
}
],
"returnValue": {
"name": "",
"type": "i64",
"schema": {
"type": "integer",
"format": "int64"
},
"required": true
},
"unpublished": false,
"deprecated": false,
"examples": [
"const sketch001 = startSketchOn('XZ')\n |> circle([0, 0], 2, %)\nconst extrude001 = extrude(5, sketch001)\n\nconst pattern01 = patternTransform(int(ceil(5 / 2)), (id) => {\n return { translate: [4 * id, 0, 0] }\n}, extrude001)"
]
},
{
"name": "lastSegX",
"summary": "Returns the last segment of x.",