In C and C++, we all know that converting a floating point value into an integer performs a truncation. That means, a fix towards zero, both for static_cast and for C style casts.
static_assert(static_cast<int>(2.9) == 2);
static_assert((int)-3.7 == -3);
To convert a floating point number into an integer, there are 4 options, each of them is implemented by a standard function from <cmath>:
roundfloorceiltrunc
I ordered the options from the most often used to the least often used, from my own experience (it is somewhat subjective).
Truncation toward zero means that all values from -0.999... to 0.999... are converted to 0. There is a for that reason a mathematical anomaly near 0, which makes truncation rarely useful. My impression is that nearly every time a programmer directly casts a floating point to an integer, he actually wants floor, but can afford trunc behavior because the value is supposed to be always positive.
My question is: what were the motivations to select the 4th option, truncate? I bet this is mostly historical, but when C was originally developed, there must have been some good reason to select truncation over the more useful rounding or flooring.