Math.trunc
Math.trunc
Function
Truncate decimals. Returns the number minus the decimal part.
Syntax
Math.trunc(value)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| value | Number | Yes | None | The number to participate in truncation. |
Return value
| Type | Description |
|---|---|
| Int/Float | Returns the number minus the decimal part. An Int is returned for integer results, and a Float for non-integer or non-finite results. |
Example
result = Math.trunc(1.8) // Output: 1 print result
Notes
- Only decimals are truncated, no rounding is done.