The issue here is with the input 16779030.
>> flintmax('single')
ans =
single
16777216
>> single(16779030)
ans =
single
16779030
>> single(16779029)
ans =
single
16779028
16779030 happens to be perfectly representable, but 16779029 is not. So minor operations, especially computing things like integer remainders, may result in precision loss.
It is a bad idea to use single precision to represent a linear index in a matrix if the total number of elements in the matrix exceeds flintmax(‘single’). This means it won’t be possible to represent every position in the matrix.
Best Answer