Truncation: Difference between revisions
From Coderwiki
More actions
new: info, truncation |
(No difference)
|
Latest revision as of 17:18, 14 August 2025
Truncation is a form of rounding where the result is always floored. This essentially means that the non-integer (decimal) part of a float is 'chopped off' (truncated).
Examples
edit edit sourceBelow some floating point numbers are shown, as well as the integers they round to when truncated:
1.2 -> 1 7.9 -> 7 8.0 -> 8 9.9 -> 9 -3.4 -> -3 -7.8 -> -7