If remaining is greater than Integer.MAX_VALUE, "(int) remaining" will be negative

When the parameter count is great than Integer.MAX_VALUE, like 
(Integer.MAX_VALUE + 1L)
then the code
(int)remaining 
will be return -2147483648