funkey Posted November 12, 2012 Share Posted November 12, 2012 (edited) Hello,I wrapped a few functions from the GMP library (http://gmplib.org/) to add and multiplicate huge integers and floats.Maybe it is useful for someone.Download: http://www.autoit.de/index.php?page=Attachment&attachmentID=16577&h=ffb11844ecb87e4fef88c05e9f9a3635d88d06f7 Edited November 14, 2012 by funkey Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
funkey Posted November 14, 2012 Author Share Posted November 14, 2012 I updated the code for using with float numbers. But I have some troubles with changing the precision. It does not take effect. Can someone please have a look at it and tell me what I'm doing wrong? Thanks Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
ValeryVal Posted November 15, 2012 Share Posted November 15, 2012 From Topic 3.7 Reentrancy of documentation"mpf_set_default_prec and mpf_init use a global variable for the selected precision. mpf_init2 can be used instead, and in the C++ interface an explicit precision to the mpf_classconstructor."So you have to call mpf_set_default_prec before any init function.1. Set precision.2. Set or init value.Other comment from 7.1 Initialization Functions:void mpf_set_default_prec (mp bitcnt t prec) [Function]Set the default precision to be at least prec bits. All subsequent calls to mpf_init will usethis precision, but previously initialized variables are unaffected.#include "GMP.au3" Global $sValue1 = "123456230290323489023430484039035832902904890289023482340234239023482349023483490890890859034809809309229342348972349" Global $sValue2 = "100" #region precision _GMPf_SetDefaultPrec(512) MsgBox(0,"","Default precision: " & _GMPf_GetDefaultPrec() & @LF) Global $t_Value1 = DllStructCreate($tag_mpf_t), $t_Value2 = DllStructCreate($tag_mpf_t) Global $p_Value1 = DllStructGetPtr($t_Value1), $p_Value2 = DllStructGetPtr($t_Value2) _GMPf_Init_Set_Str($p_Value1, $sValue1) _GMPf_Init_Set_Str($p_Value2, $sValue2) MsgBox(0,"","Precision of Value1: " & _GMPf_GetPrec($p_Value1) & @LF) $sText = StringFormat("%sn=n%snnn%sn=n%snnn", $sValue1, _GMPf_get_Str($p_Value1), $sValue2, _GMPf_get_Str($p_Value2)) MsgBox(64, "Test GMPf precision !?", $sText) _GMPf_Clear($p_Value1) _GMPf_Clear($p_Value2) $t_Value1 = 0 $t_Value2 = 0 #endregion precision The point of world view Link to comment Share on other sites More sharing options...
funkey Posted November 15, 2012 Author Share Posted November 15, 2012 Thanks for answering! That's exactly the way I tried it, but without success!? But the most important fact is, calculations with big integers work fine. Who needs floats? Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
Baraoic Posted March 27, 2013 Share Posted March 27, 2013 (edited) I have updated your UDF and compiled the latest gmp dll. I initially added the parse functions from the BigNum UDF, but I have found that function has issues. It does all of one arithmetic operation first before doing the next operation, which will cause problems at times. I plan eventually attempting to fix that, but not right now. Couple notes: by default integer functions only return 128 digits of precision, starting from most significant, but will return correct number of digits reguardless. So it will pad if needed. Sometimes the float operations return repeating digits when it shouldn't. Example _GMP_MulFloat("23", "23.4") gives .1999 repeating, but not _GMP_MulFloat("23", "23.5") and I am not sure why. Included Functions: _GMP_Parse _GMP_ParseInt _GMP_ParseFloat _GMP_HexToInt _GMP_IntToHex _GMP_AddInteger _GMP_SubInteger _GMP_MulInteger _GMP_DivInteger _GMP_PowInteger _GMP_SqrtInteger _GMP_AddFloat _GMP_SubFloat _GMP_MulFloat _GMP_DivFloat _GMP_PowFloat _GMP_SqrtFloat GMP 1.0.au3 gmp-5.1.1.zip Edited April 9, 2013 by Onichan Link to comment Share on other sites More sharing options...
Baraoic Posted April 9, 2013 Share Posted April 9, 2013 (edited) I have fixed the Parse functions and after some testing they seem to run quite a bit faster as a result. I tried to account for all the various inputs people might use in the Parse function, but I am no mathematician so I might have missed some. I do know it currently doesn't account for more than one level deep power of, for example 5^2^6 isn't calculated correctly as I haven't thought of a good way to do that yet. If there is anything else I am missing just let me know. GMP 1.1.au3 Edited April 9, 2013 by Onichan Link to comment Share on other sites More sharing options...
funkey Posted April 9, 2013 Author Share Posted April 9, 2013 Thank you for continuing this project! I'm glad someone likes it. Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
AZJIO Posted April 9, 2013 Share Posted April 9, 2013 The license allows to use this DLL in commercial projects? My other projects or all Link to comment Share on other sites More sharing options...
Baraoic Posted April 9, 2013 Share Posted April 9, 2013 GMP uses the GNU Lesser General Public License, which from the GMP site says "The license gives freedoms, but also sets firm restrictions on the use with non-free programs." So I would assume it has restrictions for commercial products. No idea about the specifics though. Link to comment Share on other sites More sharing options...
Mat Posted April 16, 2013 Share Posted April 16, 2013 I do know it currently doesn't account for more than one level deep power of, for example 5^2^6 isn't calculated correctly as I haven't thought of a good way to do that yet.Take a look I've done a lot of work on parsers since then, but I'm sure for simple expressions the code is still usable. There are C examples, but I seem to remember there being AutoIt code thrown around too. AutoIt Project Listing Link to comment Share on other sites More sharing options...
nullschritt Posted February 6, 2014 Share Posted February 6, 2014 (edited) Not to gravedig a thread, but yea, sorta.... It seems the calculations with this library return the same precision as normal autoit math? (as the dis-advantage of them taking several times as long) I need to be able to calculate high precision decimals. Edited February 6, 2014 by nullschritt Link to comment Share on other sites More sharing options...
jchd Posted February 6, 2014 Share Posted February 6, 2014 Can you describe your precise needs for arbitrary-precision arithmetic? This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
nullschritt Posted February 6, 2014 Share Posted February 6, 2014 multi-level encryption. After just a few passes I'm dealing with numbers like 2.43434343452345e+69. Eventually after enough passes the original value becomes irretrievable. Link to comment Share on other sites More sharing options...
jchd Posted February 6, 2014 Share Posted February 6, 2014 Better rely on proven algorithms scrutinized ad nauseam by professionnal cryptographers. Else you're going to silently shoot yourself in the foot with probability > 0.999999999999999999999 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
nullschritt Posted February 6, 2014 Share Posted February 6, 2014 (edited) Better rely on proven algorithms scrutinized ad nauseam by professionnal cryptographers. Else you're going to silently shoot yourself in the foot with probability > 0.999999999999999999999 I know how to code a foolproof algorithm, thanks for the advice though(I took some lessons on cryptography). I would still trust the algorithm I've devoted over 2 years into developing, beyond industry standards, for it's sheer strength compared to them. I simply want to make it even stronger. I currently only achieve about 81% accuracy when using my maximum desired encryption strength. though I can achieve 100% at levels below maximum. I'm looking into the bignum udf. Edited February 6, 2014 by nullschritt Link to comment Share on other sites More sharing options...
jchd Posted February 6, 2014 Share Posted February 6, 2014 I know how to code a foolproof algorithm, thanks for the advice though. I would still trust the algorithm I've devoted over 2 years into developing, beyond industry standards, for it's sheer strength compared to them. Amen This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
nullschritt Posted February 6, 2014 Share Posted February 6, 2014 Amen My script contains a hybris AES option, simply to mock it(in comparison of speed). Believe it or not, encryption is just glorified mathematics. It's actually possible to write an algorithm in autoit that uses far more bits, and processes the data quicker. I'll be releasing a peer-to-peer instant messenger soon to showcase the algorithm. Link to comment Share on other sites More sharing options...
Andrey_A_A Posted March 16, 2023 Share Posted March 16, 2023 Thanks for the great UDF! Whether there is a examples Random Functions? Random-Numbers Structure gmp_randstate_t ... 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