Truncate
Rounds a number so that it only includes the whole-number portion
fun truncate(number)
Parameters
- number: A number with or without units
Discussion
Any value that isn’t already a whole number has the fractional portion removed:
truncate(2.9)
truncate(2.1)
truncate(2.0)
truncate(-2.5)
2
2
2
-2
Percentages work just like regular numbers:
truncate(25.8%)
truncate(83.22%)
truncate(-9.5%)
25%
83%
-9%
truncate
also works with units:
truncate(pi radians)
truncate($25.75)
truncate(-5.5 L)
3 rad
$25
-5 L