JohnOne Posted June 18, 2010 Share Posted June 18, 2010 (edited) I wonder if anyone could help me understand how to use them/ how they work I never even heard of then before landing on this forum I'll give an example using these flags 1 2 4 8 16 32 64 If I have the number 44, how do I use the bitwise functions to decide what flags are used to arrive at that number. It looks like binary and Im one of the 0 people who understands it. Help much appreciated. Edited June 18, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
trancexx Posted June 18, 2010 Share Posted June 18, 2010 If BitAND(44, 1) Then 1 is used If BitAND(44, 2) Then 2 is used If BitAND(44, 4) Then 4 is used If BitAND(44, 8) Then 8 is used If BitAND(44, 16) Then 16 is used If BitAND(44, 32) Then 32 is used Professor_Bernd 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
JohnOne Posted June 18, 2010 Author Share Posted June 18, 2010 Thats gear that, thank you trancexx. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 18, 2010 Moderators Share Posted June 18, 2010 JohnOne,You are correct - it is binary. Are you sitting comfortably? Then let us begin....First AND and OR. An AND operation is only true if BOTH elemnts have the bit set. An OR operation is true if EITHER of the elements have the bit set:0010 AND 0111 will give 0010 because only that bit is set in BOTH 0010 OR 0111 will give 0111 because those bits are set in EITHER one of the elementsTher is also XOR, which is true only if the bits are different in each element - but we will not go there today!Look at those flags you mentioned in binary (remember we go up in powers of 2:Power of 2 7 6 5 4 3 2 1 0 Value 128 64 32 16 8 4 2 1 1 x = binary 00000001 2 x = binary 00000010 4 x = binary 00000100 ... 64 x = binary 01000000 And 44 x x x = 32 + 8 + 4 = binary 00101100So in essence you have to check whether a particulr bit is set in the number - gets complicated!But AutoIt uses the Bit* functions to help you use the decimal numbers that we (or at least some of us) are more used to dealing with. So to see if the flags 32, 8 and 4 are set we use BitAND:$iMask = 44 ; 00101100 For $i = 43 To 45 If BitAnd($i, $iTest) = $iMask Then ConsoleWrite($i & " matches!" & @CRLF) NextNote that we match both 44 and 45 as the flags are set in both cases:43 = 00101011 = __X_X_xx = not all our flags set 44 = 00101100 = __X_XX__ = all our flags set 45 = 00101101 = __X_XX_x = all our flags set - even though there are others also set!Remember we are looking at individual bits and not the whole number. If we wanted to do that we could just use If $i = $iMask. We use BitOR to add styles for a similar reason. It makes sure that only the bits associated with that particular style are set. If we added the actual values of the styles together we could end up with a number which set the wrong bits:Style 1 = 17 = 00010001 Style 3 = 33 = 00100001 If we add we get 50: 00110010 and the flag bit are wrongly set If we BitOR we get: 00110001 and the flag bits are correctly setSee the difference? Most of the time there is not a problem - but it best to use BitOr to be sure.Is that enough to be going on with? M23 pixelsearch 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Malkey Posted June 18, 2010 Share Posted June 18, 2010 (edited) I found Siao's "Bitwise operations visualiser" gave me ein wenig Verstehen, (a little understanding) of bitwise operations.Also see post #8 of that thread. Edited June 18, 2010 by Malkey Link to comment Share on other sites More sharing options...
UEZ Posted June 18, 2010 Share Posted June 18, 2010 (edited) I wrote also a converter where you can enter binary or integer value which will be converted appropriately to the other format.Integer <=> Binary ConverterBR,UEZ Edited May 2, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
JohnOne Posted June 18, 2010 Author Share Posted June 18, 2010 Im very grateful for your replys and explainations gentlebodes. Ive used these before in the likes of GUI creation but never really understood how they worked until now. Cheers. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jchd Posted June 18, 2010 Share Posted June 18, 2010 Don't forget you have a nice calculator doing most usual conversion for you: the Windows calculator. Just don't forget to switch to Scientific display to have access to numeric conversions between any two of decimal, hexadecimal, octal and binary for 8-, 16-, 32- or 64-bit wide values. 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...
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