Just found the following line in some old src code:
int e = (int)fmod(matrix[i], n);
where matrix
is an array of int
, and n
is a size_t
I'm wondering why the use of fmod
rather than %
where we have integer arguments, i.e. why not:
int e = (matrix[i]) % n;
Could there possibly be a performance reason for choosing fmod
over %
or is it just a strange bit of code?
fmod
is using floating point values which will be converted todouble
and back. So: no. For integer arithmetic, please use the%
operator.