Once in a while, I find myself rounding 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 number, and not an integer? I find this pretty non-intuitive, and would love to have some explanations!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…