In C, is there a difference between integer division a/b and floor(a/b) where both a and b are integers?
More specifically what happens during both processes?
In C, is there a difference between integer division a/b and floor(a/b) where both
Share
a/bdoes integer division. If eitheraorbis negative, the result depends on the compiler (rounding can go toward zero or toward negative infinity in pre-C99; in C99+, the rounding goes toward 0). The result has typeint.floor(a/b)does the same division, converts the result to double, discards the (nonexistent) fractional part, and returns the result as a double.