Bitwise Operations for Noobs
Working with bits
Issue: 5.2 (January/February 2007)
Author: Aaron Ballman
Article Description: No description available.
Article Length (in bytes): 18,817
Starting Page Number: 26
RBD Number: 5210
5210.zip Updated: Monday, January 15, 2007 at 1:16 PM
Related Web Link(s):
Known Limitations: None
Excerpt of article text...
If you've done any programming with REALbasic before, then chances are pretty good that you've used logical (Boolean) operators before, such as And, Or, & Not. These operators provide you with a logical way to describe a Boolean process. For instance, you may have code which says:
If UserIsAuthorized and OperationIsPermitted then DoOperation( user, operation )
If not ActionFailed then Success( "yay!" )
If Cold or Mild then MsgBox( "It's not hot out" )
These operations read as easy as English and provide your control statements with logic (hence the reason they're called logical operators). However, there's a similar class of operations called Bitwise or Arithmetic operators. These operators are very similar to logical ones in that they provide a means for describing ways of combining two operands. However, instead of involving the Boolean logic of true and false, they involve the mathematical logic of ones and zeros.
You may be thinking to yourself, "But I hate math!" Don't worry! The beauty of the two concepts is that they're generally very closely related. You can map the logical term "true" to the mathematical value "1" and "false" to "0." The main difference between logical and bitwise operations is that with bitwise operators, you're not working with just one bit of information, but a string of bits.
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.