in reply to Re: bitwise operators
in thread bitwise operators
You can take a 32 bit int and set one of the bits. Setting the 4th bit would make the integer value 8. Now why would you want to do this? A good example of this would be the data that stored in Windows NT domain accounts. I use this example because its the most recent thing I've used bitwise operators for. If you look at NT accounts, there are several "toggles" for things like "Account Locked Out", "User Must Change Password", "User Cannot Change Password", etc...
Instead of storing all of these in seperate variables, they are all stored in one integer. And if you want to test to see if the users account is locked out or unlock the account, you can test for that bit or toggle the bit, respectivly.
In smaller programs, it's probably not something that you're going to want to use. But if you're talking about a bunch of simple yes/no variables that are going to be replicated over and over again (like for accounts), you're going to save space, and I belive slightly improve speed by storing them in an integer as on/off bits.
Hope this helps...
Rich
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: bitwise operators
by wog (Curate) on May 28, 2001 at 09:30 UTC |