Try a bitwise and (I think the operator is '&')...
$value1 has bit 5 set? $value2 has bit 5 set?
- Theo
-Original Message-
From: Miguel Cruz [mailto:[EMAIL PROTECTED]]
Sent: Sunday, April 07, 2002 5:04 PM
To: Charlie Killian
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP
Thanks to all those that replied. Especially Torben. (What have you been up
to?)
Miguel's solution works great.
Check out the example below:
Prints out:
1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768,
Just what I wanted.
Thanks again,
Charlie
> > How can I te
On Sun, 2002-04-07 at 13:38, Charlie Killian wrote:
> How can I test if a number only has on bit set?
>
> So testing different numbers will return TRUE or FALSE:
>
> testing 0001 would return TRUE.
> testing 0011 would return FALSE.
>
> TIA
>
> Charlie
AND them bitwise:
Torben
--
This shows all integers from 1 to 10 that have the 2 least significant
bits set:
bvr.
Charlie Killian wrote:
>How can I test if a number only has on bit set?
>
>So testing different numbers will return TRUE or FALSE:
>
>testing 0001 would return TRUE.
>testing 0011 would return FALS
On Sun, 7 Apr 2002, Charlie Killian wrote:
> How can I test if a number only has on bit set?
>
> So testing different numbers will return TRUE or FALSE:
>
> testing 0001 would return TRUE.
> testing 0011 would return FALSE.
Think back to math class when you were 14!
function isOneBit
How can I test if a number only has on bit set?
So testing different numbers will return TRUE or FALSE:
testing 0001 would return TRUE.
testing 0011 would return FALSE.
TIA
Charlie
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.p
6 matches
Mail list logo