The only way I've seen to do it is to add 0.5 before casting. Also, if you're in C++ rather than C, you'd be better using static_cast. So your code would look like this:
thanks bnbertha for the quick reply. now i remember a bit. by adding 0.5, then floor rounding is always mathematically correct to the original ones, am i right? this must be caused of lacks of practices. thanks bnbertha!
thanks for the tips about static_cast too!