Mpro Posted February 16, 2010 Posted February 16, 2010 Hi! AutoIt developper! Here's the bug! The result of this BitAND in AutoIt is -338845696 $Temp = BitAND(3667563225088, 0xFFFFFFFF) The result is supposed to be = 3956121600 How to explain this result! 1st number too big? How calculate this number? Thanks !!!!!!!!
Richard Robertson Posted February 16, 2010 Posted February 16, 2010 Yes, it is too big. The first number is a 64 bit integer. BitAnd only works on 32 bit integers.
Mpro Posted February 16, 2010 Author Posted February 16, 2010 Is there a way to overcome this limitation ??? Split my number in half????
Richard Robertson Posted February 16, 2010 Posted February 16, 2010 Well it looks like you are trying to get the first 32 bits anyway, so something like this might work. $number = Dec(Hex(3667563225088))
martin Posted February 16, 2010 Posted February 16, 2010 Hi! AutoIt developper!Here's the bug!The result of this BitAND in AutoIt is -338845696$Temp = BitAND(3667563225088, 0xFFFFFFFF) The result is supposed to be = 3956121600How to explain this result! 1st number too big? How calculate this number?Thanks !!!!!!!!Wouldn't that be the same asConsoleWrite(Mod(3667563225088,2^32 - 1) & @CRLF)?But that gives 3956122453 not 3956121600 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.
martin Posted February 16, 2010 Posted February 16, 2010 Wouldn't that be the same asConsoleWrite(Mod(3667563225088,2^32 - 1) & @CRLF)?But that gives 3956122453 not 3956121600EDIT:second thoughts maybe it should beConsoleWrite(Mod(3667563225088,2^32 - 1) - int(3667563225088/(2^32 - 1)) & @CRLF) 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.
trancexx Posted February 16, 2010 Posted February 16, 2010 EDIT:second thoughts maybe it should beConsoleWrite(Mod(3667563225088,2^32 - 1) - int(3667563225088/(2^32 - 1)) & @CRLF)Why?Could it be Mod(3667563225088, 2^32)? ♡♡♡ . eMyvnE
jchd Posted February 17, 2010 Posted February 17, 2010 You can do some 64-bit arithmetic using that kludge. You may as well code them with "AutoIt assembler" to get rid of dependency. 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)
Richard Robertson Posted February 17, 2010 Posted February 17, 2010 Why?Could it be Mod(3667563225088, 2^32)?Mod would be the remainder after division. It wouldn't be the same result as a lower 32 bits mask.
martin Posted February 17, 2010 Posted February 17, 2010 (edited) Why?Could it be Mod(3667563225088, 2^32)?I don't think that is correct because there could be a multiple of 2^32 in the number and that will add to the value from Mod.Eg supposing X is less than 2^32 thenMod(X + 5*(2^32),2^32) = BitAnd(X + 5*(2^32),2^32) + 5My logic, or lack of it, was like thisBitAnd(16,15) = 0Mod(16,15) = 1So I thought that Mod(A,G) = BitAnd(A,G) + Int(A/G)EDIT:Here it is a bit better.Any number can be written as the sum of 2 numbers like thisD = N + G*Kwhere N < K and k is 2^p with p any value you like.BitAnd(D,K-1) is going to be N.Mod(D,K) = Mod(N + G*K,K)= Mod(Mod(N/K,G) + G),K)=N+G So N = Mod(D,K) - Gand G is Int (D/K) ThereforeBitAnd(D,K-1) = Mod(D,K) - Int(D/K)So now I'm happy that I'm right.I think I'm happy but I'll check tomorrow. Edited February 17, 2010 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.
Mpro Posted February 17, 2010 Author Posted February 17, 2010 I try it in my programm and Mod(3667563225088, 2^32) worked just fine. Mod(3667563225088, 2^32) = 3956121600 How this one. BitXOR(3956121600, 1) should be 3956121601 But in Autoit give me -338845695
jchd Posted February 17, 2010 Posted February 17, 2010 @Mpro: If you have repetitive use of such ops, try the small 64-bit code I mentionned above. @Martin: Hi, No, your result will be 1 over. Mod(X, Y) returns a result 0 <= Z < Y in all cases. AND 0x00..FF..FF mask won't touch LSB. 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)
martin Posted February 17, 2010 Posted February 17, 2010 @Martin: Hi,No, your result will be 1 over. Mod(X, Y) returns a result 0 <= Z < Y in all cases. AND 0x00..FF..FF mask won't touch LSB.Hi jchd,That makes no sense to me! Are you thinking of Div.I modified my previous post but if you can see an error in my logic please show me what it 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.
jchd Posted February 17, 2010 Posted February 17, 2010 I don't think that is correct because there could be a multiple of 2^32 in the number and that will add to the value from Mod. ... Mod(D,K) = Mod(N + G*K,K)= Mod(Mod(N/K,G) + G),K)=N+G It's there! By definition of Mod, G*K = 0 mod(K) So Mod(N + G*K, K) = N , assuming as you did that N < K. In other words the remainder of the [euclidean] division of kX by X is 0, given X <> 0. 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)
martin Posted February 17, 2010 Posted February 17, 2010 It's there! By definition of Mod, G*K = 0 mod(K) So Mod(N + G*K, K) = N , assuming as you did that N < K. In other words the remainder of the [euclidean] division of kX by X is 0, given X <> 0. I would be surprised if I what I said made sense since my posts last night were hours after I had intended to go to bed. I think I was thinking that the divisor in Mod was the value to be Anded but it is 1 more obviously. Who knows? Anyway, I was talking bollocks. Euclidean division? Is that like a Roman division? 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.
GodlessSinner Posted February 17, 2010 Posted February 17, 2010 (edited) Too big, too small, - size doesn't matter after all: expandcollapse popup#include <string.au3> MsgBox(0, "Custom BitAnd", _BitAnd(3667563225088, 4294967295)); 0xFFFFFFFF = 4294967295 ;MsgBox(0, "standard", BitAND(134, 172)) Func _BitAnd($arg1,$arg2) Local $bin = "", $bin2 = "", $result = "" While($arg1 >= 1) $arg1 /= 2 If StringIsDigit($arg1) Then $bin &= 0 Else $split = StringSplit($arg1, ".") $arg1 = $split[1] $bin &= 1 EndIf WEnd While($arg2 >= 1) $arg2 /= 2 If StringIsDigit($arg2) Then $bin2 &= 0 Else $split = StringSplit($arg2, ".") $arg2 = $split[1] $bin2 &= 1 EndIf WEnd $bin = _StringReverse($bin) $bin2 = _StringReverse($bin2) If StringLen($bin) <> StringLen($bin2) Then If StringLen($bin) > StringLen($bin2) Then $add ="" For $i = 1 To (StringLen($bin) - StringLen($bin2)) Step 1 $add &= 0 Next $bin2 = $add & $bin2 Else $add = "" For $i = 1 To (StringLen($bin2) - StringLen($bin)) Step 1 $add &= 0 Next $bin = $add & $bin EndIf EndIf $split1 = StringSplit($bin,"") $split2 = StringSplit($bin2,"") For $i = 1 To StringLen($bin) Step 1 If $split1[$i] = 0 Or $split2[$i] = 0 Then $result &= 0 ElseIf $split1[$i] = $split2[$i] And $split1[$i] = 1 Then $result &= 1 EndIf Next $split = StringSplit($result, "") $x = $split[1] For $i = 1 To StringLen($result)-1 Step 1 $x = $x * 2 + $split[$i+1] Next $result = $x Return $result EndFunc Edited February 17, 2010 by Godless _____________________________________________________________________________
Mpro Posted February 17, 2010 Author Posted February 17, 2010 Thanks Godless for your conversion/AND script. I will work on XOR script with the same base. Thanks again!
jchd Posted February 17, 2010 Posted February 17, 2010 Euclidean division? Is that like a Roman division?Just like you learnt it as a kid, remember, long, long ago ;-) and just before they thaught you this shitty decimal point. A = B * Q + R with A::dividend, B::divisor, Q::quotient, R::remainder and A, Q ∊ ℤ, B ∊ ℤ*, R ∊ ℕ, R < |Q|Probably the first equation with two unknowns that one encounters. 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)
Mpro Posted February 18, 2010 Author Posted February 18, 2010 Hi AutoIt developper! I commented the Godless script to simulate BitAnd & BitXor in Autoit! This is a great forum with a great peoples!!! Thanks again Godless!
Mpro Posted February 18, 2010 Author Posted February 18, 2010 Oooooops! Here is the script!ForumGate.au3
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