You should not be casting like this in C++.
The cast destroys the type safety of your code.
Weaknesses in C make casting a necessity but continuing to do that in C++ indicates a flawed design.
So then I would use C++'s static_cast<int>(x) . The problem with much "safe" C++ code is that it often slows the program down, not that this matters in most cases but I need to evaluate functions millions of times so I'm sensitive to this (C is hard to beat in this respect).
I guess the "correct" way to do it would be to use the function floor() which increases the memory footprint and probably the speed of my program. Worse, I could avoid C functions alltogether and use some .net functions which would then also make my program "safer", even slower and completely unportable.
At the moment, it seems my cast to int is simple and works. Do you know of a simple fast yet "safe" way to floor floating point numbers?