Re: Boolean type forced on string assignment inside if statement

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

 



Volmar Machado <qi.volmar@xxxxxxxxx> wrote:
>When the one of the operators were 2, the cases with "<------------"
>returns 2 otherwise returns 0 (Or 1 when any operator is 1). And if
>the operators are 1 and 2, return 0 too. Its curious for me.

& is the bitwise and operator. You have to look at the binary
representation of the numbers to see what is happening:
2 decimal is 0010 binary
1 decimal is 0001 binary

2 & 1 == 0010 & 0001 == 0000 == 0

In your other examples you had
2 & 3 == 0010 & 0011 == 0010 == 2
and
4 & 3 == 0100 & 0011 == 0000 == 0

Does this help?

Bye, Andreas

-- 
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