Reply to Re: Help With Bitwise Operations

Your name:

Reply:


Posted by Rob Wilkerson on 12/02/07 03:15

On Dec 1, 9:54 pm, ZeldorBlat <zeldorb...@gmail.com> wrote:
>
> FLAG_1 = 1 = 000001
> FLAG_6 = 32 = 100000
> FLAG_4 = 8 = 001000
>
> If we OR them all together we get 101001 = 41. So that's correct.
>
> Inside your function if you want to check if any particular flag was
> set you would do it like this:
>
> if($flags & FLAG_6) {
> echo 'FLAG_6 was set';}
>
> else {
> echo 'FLAG_6 was not set';
>
> }
>
> So, in your example, $flags & FLAG_6 would be true because:
>
> $flags = 41 = 101001
> FLAG_6 = 32 = 100000
>
> If we AND them together we have 100000 which, inside an if statement,
> evaluates to true.

Interesting. Then I have more learning to do. The function is one
that I'm trying to move into an object oriented context and, given
your validation that the input is correct, what I'm finding is the my
method is doing the right thing for the wrong reasons while the
original function that has always worked is doing the wrong thing for
the right reasons. Enigmatic.

I may have to follow up on this thread, but I have to do my own due
diligence even to know what question to ask.

Thanks for your help.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация