Overflow Exception
-
Is there anyway to get this expression to work without getting an overflow execption? Answer = (PublicKeyB^PrivateKeyA)Mod(PublicKeyA) the public and private keys are supposed to be 9 digit numbers example: 123456789 i've tryed using System.Math.Pow but it uses Doubles and thats the source of the overflow anyway, i would like to know if its posible and if it is, how?
-
Is there anyway to get this expression to work without getting an overflow execption? Answer = (PublicKeyB^PrivateKeyA)Mod(PublicKeyA) the public and private keys are supposed to be 9 digit numbers example: 123456789 i've tryed using System.Math.Pow but it uses Doubles and thats the source of the overflow anyway, i would like to know if its posible and if it is, how?
As you are using the Mod operator, I think that you mean the VB meaning of the ^ operator. In C# the ^ operator means an exclusive or, and doesn't cause an overflow. One nine digit number to the power of another nine digit number is way too large to fit in any integer type (unless you have a 32000000000 bit integer laying around...). It's even way too large to fit in a double or a decimal. What is it that you try to accomplish with this calculation? It doesn't really make any sense.
Despite everything, the person most likely to be fooling you next is yourself.
-
As you are using the Mod operator, I think that you mean the VB meaning of the ^ operator. In C# the ^ operator means an exclusive or, and doesn't cause an overflow. One nine digit number to the power of another nine digit number is way too large to fit in any integer type (unless you have a 32000000000 bit integer laying around...). It's even way too large to fit in a double or a decimal. What is it that you try to accomplish with this calculation? It doesn't really make any sense.
Despite everything, the person most likely to be fooling you next is yourself.
the formula i wrote there is not any kind of code, it is written in human language, i know for ^ i should use Pow(base,exponent) and for Modulus i should use %; it is supposed to be a formula to calculate a value in order to calculate another value to prove the basis of cryptography to my teacher in classroom. (it is supposed to be somehting simple) anyway, i just wanted to know if it was possible to do without getting an overflow
-
Is there anyway to get this expression to work without getting an overflow execption? Answer = (PublicKeyB^PrivateKeyA)Mod(PublicKeyA) the public and private keys are supposed to be 9 digit numbers example: 123456789 i've tryed using System.Math.Pow but it uses Doubles and thats the source of the overflow anyway, i would like to know if its posible and if it is, how?