This is the function I am using to decrypt a value using the RSA method. I seem to be having a problem with the fmod() function.

I have followed the function through with a debugger and get the following results:

The values of the variables are:

C = 33

PrivKey = 29

ModKey = 91

Power = pow (C, PrivKey) = 1.088690056823e+044

M = fmod (Power, ModKey) = 87

I have performed the calculations on Windows’ calculator and get the same result for the power operation but get a value of 24 after the Mod operation. This is the correct value (the initial value before encryption). There is obviously an error occurring with the fmod() function but I don’t see what it is. M, Power and ModKey are all doubles so there shouldn’t be a problem there. Anyone know why I am getting this error? Thanks.

My function:

Code:void CipherDecrypt::DecryptData (double input) { C = input; cout << "Decrypt" << endl << "C: " << C << endl; Power = pow (C, PrivKey); cout << "Power: " << Power << endl; M = fmod (Power, ModKey); cout << "M: " << M << endl; }