I think every single time I've used Math.Ceiling or its language variant, I've always had to cast it to an integer. I mean... that's the whole point, isn't it? To get a whole number. So why doesn't it just return an int?
Tell me more
×
Programmers Stack Exchange is a question and answer site for
professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.
|
|
|||
|
|
|
For one, REALs/FLOATs usually have a much greater range. The result might not fit into an INTEGER. |
|||||||||||
|
|
Smalltalk's does.
100000000000000000000 is a LargePositiveInteger, meaning an integer that uses more than 32 bits in its representation. As Michael points out, the above answer is wrong. I didn't notice that while the answer was an integer the answer was wrong because the float loses precision. So instead here's another, CORRECT, version, which works because we don't use floats:
|
|||||||||||
|