When it comes to mathematics, truncating and rounding are two different operations that can be used to modify numbers. Truncating effectively discards any digits after the decimal point, while round calculates the number closest to the input with a specified degree of accuracy. It is important to understand the difference between these two operations in order to use them correctly. An easy way to truncate a positive value is to subtract 0.5 from it and then round it.

This algorithm differs slightly depending on whether a positive value (greater than or equal to zero) or a negative value (less than zero) is truncated. Note that the domains of the truncation function and the rounding function for any given return value are offset exactly 0.5.When Excel is truncated, it trims part of the entered number and does not perform any rounding. If you are trying to round to 2 decimal places, it is recommended to use Round () instead of Truncate (), as this will make the code more readable and maintainable. The floor function receives and returns a double value, so for simplicity's sake, let's look at the algorithm for truncating positive numbers.