Skip to content

trunc

Truncate toward zero.

v = trunc(number)

Returns the integer part of number by removing the fractional component. Differs from int for negatives: trunc(-2.5) = -2 (toward zero), int(-2.5) = -3 (toward minus infinity).

trunc(8.7) % 8
trunc(-8.7) % -8
  • int — Round down to the nearest integer.
  • floor — Round toward negative infinity.
  • round — Round to the nearest integer (or to a specified number of digits).