Re: Help with some clever bit operations

From: Date: Tue, 13 Jun 2006 11:14:19 +0000
Subject: Re: Help with some clever bit operations
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-237879@lists.php.net to get a copy of this message
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

« previous php.general (#237879) next »