Coolsurfer Posted April 30, 2005 Share Posted April 30, 2005 Is their anyway that I can compare 2 large integers with 33 digits? It seem that AutoIt treats small differences as equal probably because it uses a scientific notation which chops off a lot of numbers. is their anyway around this? Example I want AutoIt to recognize the difference between 16777215167772081677721513668432 And 16777215167772081473348016312512 Is it possible? Link to comment Share on other sites More sharing options...
VicTT Posted April 30, 2005 Share Posted April 30, 2005 Only if you represent the numbers through arrays so that every digit would be an array element..and then simulate every operation you need done..That's how I would have done it in a "classical" programming language..I have no idea if AutoIt has any special functions to handle such numbers, or anything of the sort..It *CAN* be done, but it's a real hassle to multiply 2 such numbers..the addition function is simple, but say if you have "numbers"(digit arrays) A and B and want A*B, you would need a function to multiply the 2 arrays which can't be simulated by repetitive addition, because the for accepts only integer vars..anyway..it's a complicated matter..hope I didn't rant on the wrong subject too much..But I thought this is what you were actually asking.. Quote Together we might liveDivided we must fall Link to comment Share on other sites More sharing options...
Coolsurfer Posted April 30, 2005 Author Share Posted April 30, 2005 Only if you represent the numbers through arrays so that every digit would be an array element..and then simulate every operation you need done..That's how I would have done it in a "classical" programming language..I have no idea if AutoIt has any special functions to handle such numbers, or anything of the sort..It *CAN* be done, but it's a real hassle to multiply 2 such numbers..the addition function is simple, but say if you have "numbers"(digit arrays) A and B and want A*B, you would need a function to multiply the 2 arrays which can't be simulated by repetitive addition, because the for accepts only integer vars..anyway..it's a complicated matter..hope I didn't rant on the wrong subject too much..But I thought this is what you were actually asking..<{POST_SNAPBACK}>So then what is the maximum number of digits that I can use? If necessary I can break up the larger numbers. Link to comment Share on other sites More sharing options...
buzz44 Posted April 30, 2005 Share Posted April 30, 2005 You can do almost anything with AutoIt. It depends in what way you want to compare the 2 numbers. There are many different choices... A-B, thats a difference. You might want to compare each digit individually. Example A = 16777215167772081677721513668432 B = 16777215167772081473348016312512 Comparison = 0000000000000000020427503356120 Digits are the same in both numbers represented by a 0, and ones that arnt I minused the smallest number out of the digits. As I said before it depends by what means you want to compare them. qq Link to comment Share on other sites More sharing options...
Coolsurfer Posted April 30, 2005 Author Share Posted April 30, 2005 You can do almost anything with AutoIt.It depends in what way you want to compare the 2 numbers. There are many different choices... A-B, thats a difference. You might want to compare each digit individually.ExampleA = 16777215167772081677721513668432 B = 16777215167772081473348016312512 Comparison = 0000000000000000020427503356120Digits are the same in both numbers represented by a 0, and ones that arnt I minused the smallest number out of the digits.As I said before it depends by what means you want to compare them.<{POST_SNAPBACK}>I've done A-B but Auto-it did not notice the difference. When I subtracted one from the other all it returns is 0. All I need is a method that shows a difference for an If-Then statement. Link to comment Share on other sites More sharing options...
buzz44 Posted April 30, 2005 Share Posted April 30, 2005 (edited) I've done A-B but Auto-it did not notice the difference. When I subtracted one from the other all it returns is 0. All I need is a method that shows a difference for an If-Then statement.<{POST_SNAPBACK}>$a = 16777215167772081677721513668432 $b = 16777215167772081473348016312512 $c = $a - $b Msgbox(0,"test",$c)Works for me.And.$a = 16777215167772081677721513668432 $b = 16777215167772081473348016312512 If $a = $b Then Msgbox(0,"Same","The 2 numbers are the same!") Else Msgbox(0,"Diff","The 2 numbers are different!" & @CRLF & "Difference: " & $a - $b) EndIf Edited April 30, 2005 by Burrup qq Link to comment Share on other sites More sharing options...
Coolsurfer Posted April 30, 2005 Author Share Posted April 30, 2005 (edited) $a = 16777215167772081677721513668432 $b = 16777215167772081473348016312512 $c = $a - $b Msgbox(0,"test",$c)Works for me.And.$a = 16777215167772081677721513668432 $b = 16777215167772081473348016312512 If $a = $b Then Msgbox(0,"Same","The 2 numbers are the same!") Else Msgbox(0,"Diff","The 2 numbers are different!" & @CRLF & "Difference: " & $a - $b) EndIf<{POST_SNAPBACK}>Why does the addition of the array change things?$a = 16777215167772081677721513668432$b = 16777215167772081473348016312512Dim $c[2]$c[0] = $a$c[1] = $bIf $a = $b Then Msgbox(0,"Same","The 2 numbers are the same!(a andb)")Else Msgbox(0,"Diff","The 2 numbers are different!")EndIfIf $c[0] = $c[1] Then Msgbox(0,"Same","The 2 numbers are the same!c[]")Else Msgbox(0,"Diff","The 2 numbers are different!")EndIf Edited April 30, 2005 by Coolsurfer Link to comment Share on other sites More sharing options...
buzz44 Posted April 30, 2005 Share Posted April 30, 2005 It doesn't for me... Both return "The 2 numbers are different!", are you sure you have a latest BETA or 3.1.1 stable version. qq Link to comment Share on other sites More sharing options...
VicTT Posted April 30, 2005 Share Posted April 30, 2005 Why does the addition of the array change things?$a = 16777215167772081677721513668432$b = 16777215167772081473348016312512Dim $c[2]$c[0] = $a$c[1] = $bIf $a = $b Then Msgbox(0,"Same","The 2 numbers are the same!(a andb)")Else Msgbox(0,"Diff","The 2 numbers are different!")EndIfIf $c[0] = $c[1] Then Msgbox(0,"Same","The 2 numbers are the same!c[]")Else Msgbox(0,"Diff","The 2 numbers are different!")EndIf<{POST_SNAPBACK}>You didn't quite get me..you declare yourself an array a2..and each element is a digit of a..so a[1]=1, a[2]=6 aso ... a[32]=3 a[33]=2..and then you would build a funct. that would substract b2, array built using the same method from a2..If it's only addition and that substraction, it's pretty easy.. Quote Together we might liveDivided we must fall Link to comment Share on other sites More sharing options...
Coolsurfer Posted April 30, 2005 Author Share Posted April 30, 2005 It doesn't for me... Both return "The 2 numbers are different!", are you sure you have a latest BETA or 3.1.1 stable version.<{POST_SNAPBACK}>version is old, so I'll get the new one and let you know. Link to comment Share on other sites More sharing options...
VicTT Posted April 30, 2005 Share Posted April 30, 2005 (edited) Ok..that was REALLY vague..sorry..I'm really tired.. a2=123456 b2=789012 ;Substract b2 from a2 digit by digit, starting from the end.. That's easy to implement.. and a2 and b2 are arrays.. Edited April 30, 2005 by VicTT Quote Together we might liveDivided we must fall Link to comment Share on other sites More sharing options...
buzz44 Posted April 30, 2005 Share Posted April 30, 2005 It worked correctly. 1st message box, "The 2 numbers are the same!", 2nd, "The 2 numbers are different!". Tested with BETA 3.1.1.18 qq 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