Please spend some time reading this.
Maths() topic http://www.autohotke...matics-library/
Direct download v2.4 https://raw.github.c...tions/Maths.ahk
Variables when assigned at places near to or in the function call in which they are used give wrong results.
What I simply mean is --
var := "-" SM_Multiply(Divisor, div) ;done because of a bug or something if div = 0 Remainder := 0 else Remainder := SM_Add(dividend, var)
and
if div = 0 Remainder := 0 else Remainder := SM_Add(dividend, "-" SM_Multiply(Divisor, div))
give different results at random situations. As the var doesn't changes anywhere in the middle, the second code seems theoretically correct. But the truth is that second code fails at random situations.
An example to prove this
Please note that the two codes are part of SM_Mod() function in the lib. The second one (snippet:2) is the one included in the v2.4
Try this code in the 2.4 version (link available right at the top)
msgbox,% SM_Mod( SM_Pow(3,77), 79) ;Mod of 3**77 when divided by 79
The answer should be something less than 79 a/c Maths (actually 53) but the answer comes out to be a 20-digit number
Note that there isn't a bug in SM_Mod() func, you can check simpler or known combos to confirm
Next try replacing the snippet:2 (which is a part of SM_Mod()) with snippet:1, and it will work with 3,77 example.
Any explanations on this ?
Lexikos ?
I have also tried something like this --
if div = 0 Remainder := 0 else { var := "-" SM_Multiply(Divisor, div) Remainder := SM_Add(dividend, var) }
This too fails ..