Re: Help with some clever bit operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday 13 June 2006 12:18, David Tulloh wrote:

> The example starting values
> $existing = 181; # = 10110101
> $new = 92; # = 01011100
> $mask = 15; # = 00001111
> 
> Get the bits that will be changed
> $changing = $new & $mask; # = 12 = 00001100
> 
> Get the bits that won't be changed
> $staying = $existing & ~$mask; # = 176 = 10110000
> 
> Combine them together
> $result = $changing ^ $staying; # = 188 = 10111100
> 
> 
> David
[snip]

Thank you very much, I appreciate it!

Niels

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux