We have seen that modulus operator (%) does not support floating point numbers.
(If you have any doubt regarding this visit http://implementc.blogspot.in/2013/12/trap-1-error-illegal-use-of-floating.html ).
If you want to know the reason behind this then continue reading :
Any arithmetic operation between :
1. int and int = int
2. int and float = float
3. float and float = float
What a%b does is give the remainder of the two numbers. And remainder of any division will always be an integer value. Floating point remainder of any division has no meaning. Think about it.
So if you are using modulus operator with floating point numbers then according to Arithmetic Operation Table result will also have to be floating point number.
How can a remainder of division be a floating type of number??
So modulus of two floating point number has no meaning.
(If you have any doubt regarding this visit http://implementc.blogspot.in/2013/12/trap-1-error-illegal-use-of-floating.html ).
If you want to know the reason behind this then continue reading :
Any arithmetic operation between :
1. int and int = int
2. int and float = float
3. float and float = float
What a%b does is give the remainder of the two numbers. And remainder of any division will always be an integer value. Floating point remainder of any division has no meaning. Think about it.
So if you are using modulus operator with floating point numbers then according to Arithmetic Operation Table result will also have to be floating point number.
How can a remainder of division be a floating type of number??
So modulus of two floating point number has no meaning.