It is not haskell specific, but there is a difference between these functions. Floor means the highest integer not exceeding the given number. Truncation means removing at a certain length, in this case a fractional part. They have the same effect for zero and positive numbers, but are not negative.
Here's a quick comparison in Python:
>>> for i in range(-5,6): ... j=0.5*i ... print(j,floor(j),ceil(j),trunc(j),round(j)) ... -2.5 -3 -2 -2 -2 -2.0 -2 -2 -2 -2 -1.5 -2 -1 -1 -2 -1.0 -1 -1 -1 -1 -0.5 -1 0 0 0 0.0 0 0 0 0 0.5 0 1 0 0 1.0 1 1 1 1 1.5 1 2 1 2 2.0 2 2 2 2 2.5 2 3 2 2
Essentially, trunc () goes to zero and floor () to negative infinity.
Yann vernier
source share