Why are there no residual division operations for float / double in C and C ++?

Possible duplicate:
Why %does modular division ( ) work only with integers?

This code does not work in C and C ++, but it works in C # and Java:

float x = 3.4f % 1.1f;
double x = 3.4 % 1.1;

In addition, the remainder of division is defined for reals in Python.

What is the reason why this operation is not defined for float and double in C and C ++?

+5
source share
1 answer

Committee C explained why there is no remainder operator for floating types in the Rationale document :

(6.5.5 Multiplicative operators) The C89 committee rejected the extension of the% operator for working with floating types, since this use duplicates the object provided by fmod (see §7.12.10.1).

+20

All Articles