3 ms·
Let me try to break it down: (max - min) is int ((long) key - min) is long long / int is long since a long is involved. (size - 1) is int int * long
by huherto 16y ago
Let me try to break it down:
(max - min) is int
((long) key - min) is long
long / int is long since a long is involved.
(size - 1) is int
int * long is long
I think the purpose if the long cast is that the last multiplication produces a long and it doesn't overflow. But then it is casted to an int anyway defeating the purpose.
- feijai 16y ago> (max - min) is int Incorrect. These are signed values. If you subtract a large negative integer from a large positive integer, the result is larger than an integer.