I’m going to guess here (cause I feel this community is for learning)…
Integers have exactness. Doubles have range.
So if MAX_INT + 1 is possible, then ~(MAX_INT + 1) is probably preferable to an overflow or silent MIN_INT.
But Math.ceil probably expects a float, because it is dealing with decimals (or similar). If it was an int, rounding wouldn’t be required.
So if Math.ceil returned and integer, then it could parse a float larger than INT_MAX, which would overflow an int (so error, or overflow). Or just return a float
I’m going to guess here (cause I feel this community is for learning)…
Integers have exactness. Doubles have range.
So if
MAX_INT + 1
is possible, then~(MAX_INT + 1)
is probably preferable to an overflow or silentMIN_INT
.But
Math.ceil
probably expects a float, because it is dealing with decimals (or similar). If it was an int, rounding wouldn’t be required.So if
Math.ceil
returned and integer, then it could parse a float larger than INT_MAX, which would overflow an int (so error, or overflow). Or just return a float