I have some very simple C++ code:
#include "stdafx.h"
#include "math.h"
int main(int argc, char* argv[])
{
long double i,t,c;
i = 16;
t = 27;
c = powl(i, t);
printf ("%f", c );
printf ("\n");
return 0;
}
According to Microsoft's calculation in Windows, 16^27 is:
3.2451855365842672678315602057626e+32
According to C++ it is:
324518553658426730000000000000000.000000
Why is this difference in precision happening? It must be completely precise, I am trying to make something simple that will encrypt a message in RSA"
Cipher text = Message **_^ E_** Mod N
If the exponent isn't computed precisely, it will come out incorrect.
Is there anything else that I could define that would be completely precise and hold that large of a number? If someone could direct me towards a class that would do precise math such as this it would be greatly appreciated.
add a comment