# Very large numbers

## Recommended Posts

Hiya,

For my script I have to use very, very large numbers.

AutoIt can't hold very large numbers in it's vars.

Is there any way that I can make AutoIt or via AI calculate something like: 545^503? (Or much larger numbers)

This sum is used in this formula: Mod(\$c^\$d, \$n) <-- \$c=545, \$d=503 & \$n=943

Even MS Excel 2007 can't do this one. But strangly enough, the simple Windows calculator can... (2.5552926463997007731368876053147e+1376)

Im not a mathematician, so is there a way I can transform that sum into something manageable?

The outcome of that formula is 35.

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

##### Share on other sites

Hiya,

For my script I have to use very, very large numbers.

AutoIt can't hold very large numbers in it's vars.

Is there any way that I can make AutoIt or via AI calculate something like: 545^503? (Or much larger numbers)

This sum is used in this formula: Mod(\$c^\$d, \$n) <-- \$c=545, \$d=503 & \$n=943

Even MS Excel 2007 can't do this one. But strangly enough, the simple Windows calculator can... (2.5552926463997007731368876053147e+1376)

Im not a mathematician, so is there a way I can transform that sum into something manageable?

The outcome of that formula is 35.

There is no way any standard windows calculator can do that calculation so that you can solve

Mod(\$c^\$d, \$n) <-- \$c=545, \$d=503 & \$n=943

The answer you showed might well be correct to the number of digits given, but to get the correct answer for mod 943 (or mod any number) you have to know the answer to the very last digit. That means knowing the answer exactly for a number 1377 digits long.

I think you need another approach.

If you have 2 numbers multiplied like this

Mod(w*P,Y)

then if Y < P then I image the answer will be the same as

Mod(w*mod(P,Y),Y)

If that is correct then you could make the calculation quite manageable with a little loop.

Needs to be checked but the idea looks right to me at the moment.

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

##### Share on other sites

I think that was right.

say you have 2 numbers A and B

And you want the mod of A*B

If B is bigger than M then

A*B = A*(N*M + X) where N*M + X = B

Mod(A*(N*M + X),M) = MOD(A*N*M + A*X,M)

but A*N*M can be ignored because obviously it's a multiple of M

Mod(A*B,M) = Mod(A*Mod(B,M),M)

```Global \$c=545, \$d=503 , \$n=943
\$res = \$c
for \$z = 2 to \$d
\$res *= \$c
\$res = Mod(\$res,\$n)
Next
ConsoleWrite(\$res & @CRLF)```

which gives 35.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

##### Share on other sites

There is no way any standard windows calculator can do that calculation so that you can solve

Mod(\$c^\$d, \$n) <-- \$c=545, \$d=503 & \$n=943

But it can!

Just type in: 545 {x^y } 503 {mod} 943

Even without the mod it can display the number (as far as something can display something with 1300+ numbers)

Anyway, you second code seemed to work, but even that failed with larger numbers.

Try \$c = 1.46467147945254e+022, \$d = 2753 and \$n = 3233

That is way to large for even you find code to process

Could there be a way that I could pass my calculation to some Windows part and get the result back from it? (Except ControlSend some buttons to calc)

Edit: I forgot to thank you! Well, thanks for trying to help me!

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

##### Share on other sites

But it can!

Just type in: 545 {x^y } 503 {mod} 943

Even without the mod it can display the number (as far as something can display something with 1300+ numbers)

Anyway, you second code seemed to work, but even that failed with larger numbers.

Try \$c = 1.46467147945254e+022, \$d = 2753 and \$n = 3233

That is way to large for even you find code to process

Could there be a way that I could pass my calculation to some Windows part and get the result back from it? (Except ControlSend some buttons to calc)

Edit: I forgot to thank you! Well, thanks for trying to help me!

I am a bit sceptical about these numbers you are using. Is 1.46467147945254e+022 really

14646714794525400000000? If not then without knowing the last digits you can never know what the modulus of the number is.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

##### Share on other sites

But I can't get the real number out of the system

Inside it does calculate with the right numbers (as far as it can go), but somehow it won't show it to me

But it was meant as an example as how large the number could be. If I use the numbers I intend to use, the will be many times larger

(That because I intent to use it in an encryption and multiplying large prime numbers etc)

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

## Create an account

Register a new account

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...