Possible Duplicate:
Reference - What does this symbol mean in PHP?
When I was reading this php page, I was not sure what & is doing in $var & 1.
function odd($var) { // returns whether the input integer is odd return($var & 1); }
Is it returning a reference? I am not sure.
If you can explain it or direct me a php page, I will appreciate it.
Thanks in advance.
"What Is Love" was written and produced by German music producer and composer Dee Dee Halligan (Dieter Lünstedt a.k.a. Tony Hendrik) and his partner/wife Junior Torello (Karin Hartmann-Eisenblätter a.k.a. Karin van Haaren) of Coconut Records in Hennef (Sieg) near Cologne.
"Live Twice" is the title track and the second single from Scottish singer Darius's second album, Live Twice (2004). The song was released on 10 January 2005 as his sixth and final single. It peaked at number seven on the UK Singles Chart and number 24 in Ireland.
According to JYP Entertainment, the song is about "the love girls would dream about or imagine after learning about it through books, movies or dramas" and it has a bright melody and uptempo dance beat incorporating trap.
It's a bitwise-AND operation. All odd numbers have LSB (least significant bit set to 1), even numbers - 0.
So it simply "ANDs" two numbers together. For example, 5. It is represented as 101 in binary. 101 & 001 = 001 => true, so it is odd.
It is performing bitwise ANDing. That is a bitwise operator
$a & $b Bits that are set in both $a and $b are set.
In this case, return($var & 1);
will do a bitwise AND against 0000....0001
returning 1 or 0 depending on the last bit of $var
.
If the binary representation of a number ends in 0, it is even (in decimal).
If the binary representation of a number ends in 1, it is odd (in decimal).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With