Files
modeling-app/docs/kcl/int.md
2024-10-28 11:45:54 -04:00

118 KiB

title, excerpt, layout
title excerpt layout
int Convert a number to an integer. 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.

int(num: number) -> i64

Tags

  • convert

Arguments

Name Type Description Required
num number Yes

Returns

i64

Examples

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] }
}, %)

Rendered example of int 0