The example starting values
$existing = 181; # = 10110101
$new = 92; # = 01011100
$mask = 15; # =
Get the bits that will be changed
$changing = $new $mask; # = 12 = 1100
Get the bits that won't be changed
$staying = $existing ~$mask; # = 176 = 1011
Combine them together
Niels wrote:
Hi,
I have a problem I can solve with some loops and if-thens, but I'm sure it
can be done with bit operations -- that would be prettier. I've tried to
work it out on paper, but I keep missing the final solution. Maybe I'm
missing something obvious...
The problem: A function
David Tulloh wrote:
The example starting values
$existing = 181; # = 10110101
$new = 92; # = 01011100
$mask = 15; # =
Get the bits that will be changed
$changing = $new $mask; # = 12 = 1100
Get the bits that won't be changed
$staying = $existing ~$mask; # = 176 =
On 13 June 2006 10:31, Niels wrote:
Hi,
I have a problem I can solve with some loops and if-thens,
but I'm sure it
can be done with bit operations -- that would be prettier.
I've tried to
work it out on paper, but I keep missing the final solution. Maybe
I'm missing something obvious...
On Tuesday 13 June 2006 12:32, Ford, Mike wrote:
On 13 June 2006 10:31, Niels wrote:
Hi,
I have a problem I can solve with some loops and if-thens,
but I'm sure it
can be done with bit operations -- that would be prettier.
I've tried to
work it out on paper, but I keep missing the
On Tuesday 13 June 2006 12:22, Jochem Maas wrote:
Niels wrote:
Hi,
I have a problem I can solve with some loops and if-thens, but I'm sure
it can be done with bit operations -- that would be prettier. I've tried
to work it out on paper, but I keep missing the final solution. Maybe I'm
On Tuesday 13 June 2006 12:18, David Tulloh wrote:
The example starting values
$existing = 181; # = 10110101
$new = 92; # = 01011100
$mask = 15; # =
Get the bits that will be changed
$changing = $new $mask; # = 12 = 1100
Get the bits that won't be changed
$staying =
- Original Message -
From: David Tulloh [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Tuesday, June 13, 2006 12:18 PM
Subject: Re: [PHP] Help with some clever bit operations
The example starting values
$existing = 181; # = 10110101
$new = 92
On Tue, 2006-06-13 at 06:22, Jochem Maas wrote:
My brain needs a crutch when trying doing this kind of thing
(normally I only write hex number literally when dealing with bitwise stuff -
the conversion stuff still makes my head spin) - this is what this table is
for:
128 64 32 16 8 4 2 1
Robert Cummings wrote:
On Tue, 2006-06-13 at 06:22, Jochem Maas wrote:
My brain needs a crutch when trying doing this kind of thing
(normally I only write hex number literally when dealing with bitwise stuff -
the conversion stuff still makes my head spin) - this is what this table is
for:
On Tue, 2006-06-13 at 11:03, Jochem Maas wrote:
Robert Cummings wrote:
On Tue, 2006-06-13 at 06:22, Jochem Maas wrote:
My brain needs a crutch when trying doing this kind of thing
(normally I only write hex number literally when dealing with bitwise
stuff -
the conversion stuff still
Robert Cummings wrote:
On Tue, 2006-06-13 at 11:03, Jochem Maas wrote:
Robert Cummings wrote:
On Tue, 2006-06-13 at 06:22, Jochem Maas wrote:
My brain needs a crutch when trying doing this kind of thing
(normally I only write hex number literally when dealing with bitwise
stuff -
the
12 matches
Mail list logo