← TechnologyThe essentials of

Math.trunc(): fraction removal

Publisher: ResumeMaker • 1 source

Published: 22 Oct 2026 13:13 · Updated: 22 Oct 2026 13:13

AI source check: 21 Oct 2026 12:40. This is not editorial approval.

In a few sentences

In brief

For positive and negative numbers, the direction is towards zero.

Useful to know

Math.trunc() removes the fractional part of a number. Math.trunc(3.9) is 3, and Math.trunc(-3.9) is -3. For negative inputs this differs from Math.floor(). [1]

Use it when the task is actually a cutoff, not the nearest integer. For example, showing only the whole completed units may require such a result, but a negative deficiency is interpreted separately. The clear name of the operation helps when reviewing code: "whole part", "lower bound" and "rounded" are not interchangeable concepts.

Sources

For further detail and to check the information:

  1. [1] MDN — Math.trunc ↗