From time to time, I find that I am rounding off some numbers, and I always have to cast the result to an integer:
int rounded = (int) floor(value);
Why do all rounding functions ( ceil()
, floor()
) return a floating-point number rather than an integer? I find this rather unintuitive and would like some explanation!
c ++ c casting rounding
Wookai Aug 10 '09 at 8:16 2009-08-10 08:16
source share