Triblade Posted August 6, 2008 Share Posted August 6, 2008 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) Link to comment Share on other sites More sharing options...
martin Posted August 6, 2008 Share Posted August 6, 2008 (edited) 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=943Even 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=943The 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 thisMod(w*P,Y)then if Y < P then I image the answer will be the same asMod(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 August 6, 2008 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. Link to comment Share on other sites More sharing options...
martin Posted August 6, 2008 Share Posted August 6, 2008 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 so the answer is Mod(A*B,M) = Mod(A*Mod(B,M),M) This means the answer to your question is 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. Link to comment Share on other sites More sharing options...
Triblade Posted August 7, 2008 Author Share Posted August 7, 2008 (edited) 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=943But it can!Just type in: 545 {x^y } 503 {mod} 943Even 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 = 3233That 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! Edited August 7, 2008 by Triblade My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger) Link to comment Share on other sites More sharing options...
martin Posted August 7, 2008 Share Posted August 7, 2008 But it can!Just type in: 545 {x^y } 503 {mod} 943Even 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 = 3233That 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 really14646714794525400000000? 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. Link to comment Share on other sites More sharing options...
Triblade Posted August 7, 2008 Author Share Posted August 7, 2008 Your right about being sceptical about it. 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) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now