I'm studying K&R. I'm on exercise 4.3. Part of the exercise requires me to calculate the remainder of two double types.

The following code isn't working for me, though:

I just copied some math that I seen online somewhere to make this function. If I try to calculate 10.0 % 3.0, it returns 0.0. I don't understand why.Code:double get_mod(double num, double den) { double quotient; quotient = num/den; return (num - quotient * den); //this math should produce the remainder }

The K&R answer book suggests that I use the function fmod(), which returns the mod of two double types. I would like to figure it out myself, though.

Could someone point me in the right direction? Thanks.