Connecting Tech Pros Worldwide Forums | Help | Site Map

binary and & vs &=

joshuajnoble
Guest
 
Posts: n/a
#1: Nov 9 '07
Is there any difference between doing:

$var & 0x80;

and

$var &= 0x80;

I've seen the second, using the &= in production code, but on my local
machine it errors out. Any thoughts?


Steve
Guest
 
Posts: n/a
#2: Nov 9 '07

re: binary and & vs &=



"joshuajnoble" <joshuajnoble@gmail.comwrote in message
news:1194618918.690991.128490@v23g2000prn.googlegr oups.com...
Quote:
Is there any difference between doing:
>
$var & 0x80;
doesn't not effect the value of $var.
Quote:
and
>
$var &= 0x80;
assigns the result of ($var & 0x80) to $var.
Quote:
I've seen the second, using the &= in production code, but on my local
machine it errors out. Any thoughts?
what error message are you getting?


Rik Wasmus
Guest
 
Posts: n/a
#3: Nov 9 '07

re: binary and & vs &=


On Fri, 09 Nov 2007 15:42:13 +0100, Steve <no.one@example.comwrote:
Quote:
"joshuajnoble" <joshuajnoble@gmail.comwrote in message
news:1194618918.690991.128490@v23g2000prn.googlegr oups.com...
Quote:
>Is there any difference between doing:
>>
>$var & 0x80;
>
doesn't not effect the value of $var.
>
Quote:
>and
>>
>$var &= 0x80;
>
assigns the result of ($var & 0x80) to $var.
>
Quote:
>I've seen the second, using the &= in production code, but on my local
>machine it errors out. Any thoughts?
>
what error message are you getting?
On it's own, the error would be a notice that $var is undefined.
--
Rik Wasmus
Steve
Guest
 
Posts: n/a
#4: Nov 9 '07

re: binary and & vs &=



"Rik Wasmus" <luiheidsgoeroe@hotmail.comwrote in message
news:op.t1i5a5dq5bnjuv@metallium.lan...
On Fri, 09 Nov 2007 15:42:13 +0100, Steve <no.one@example.comwrote:
Quote:
"joshuajnoble" <joshuajnoble@gmail.comwrote in message
news:1194618918.690991.128490@v23g2000prn.googlegr oups.com...
Quote:
>Is there any difference between doing:
>>
>$var & 0x80;
>
doesn't not effect the value of $var.
>
Quote:
>and
>>
>$var &= 0x80;
>
assigns the result of ($var & 0x80) to $var.
>
Quote:
>I've seen the second, using the &= in production code, but on my local
>machine it errors out. Any thoughts?
>
what error message are you getting?
Quote:
On it's own, the error would be a notice that $var is undefined.
that's all i could figure too...so i had to ask.


Darko
Guest
 
Posts: n/a
#5: Nov 9 '07

re: binary and & vs &=


On Nov 9, 3:35 pm, joshuajnoble <joshuajno...@gmail.comwrote:
Quote:
Is there any difference between doing:
>
$var & 0x80;
>
and
>
$var &= 0x80;
>
I've seen the second, using the &= in production code, but on my local
machine it errors out. Any thoughts?
$var &= 0x80 <= $var = $var & 0x80

Steve
Guest
 
Posts: n/a
#6: Nov 9 '07

re: binary and & vs &=



"Darko" <darko.maksimovic@gmail.comwrote in message
news:1194624540.774587.257620@o3g2000hsb.googlegro ups.com...
Quote:
On Nov 9, 3:35 pm, joshuajnoble <joshuajno...@gmail.comwrote:
Quote:
>Is there any difference between doing:
>>
>$var & 0x80;
>>
>and
>>
>$var &= 0x80;
>>
>I've seen the second, using the &= in production code, but on my local
>machine it errors out. Any thoughts?
>
$var &= 0x80 <= $var = $var & 0x80

perhaps <=is a non-standard equality to the op. you mean that both
accomplish the same thing...they are just two different ways of writing the
same thing, right?


Darko
Guest
 
Posts: n/a
#7: Nov 9 '07

re: binary and & vs &=


On Nov 9, 7:11 pm, "Steve" <no....@example.comwrote:
Quote:
"Darko" <darko.maksimo...@gmail.comwrote in message
>
news:1194624540.774587.257620@o3g2000hsb.googlegro ups.com...
>
Quote:
On Nov 9, 3:35 pm, joshuajnoble <joshuajno...@gmail.comwrote:
Quote:
Is there any difference between doing:
>
Quote:
Quote:
$var & 0x80;
>
Quote:
Quote:
and
>
Quote:
Quote:
$var &= 0x80;
>
Quote:
Quote:
I've seen the second, using the &= in production code, but on my local
machine it errors out. Any thoughts?
>
Quote:
$var &= 0x80 <= $var = $var & 0x80
>
perhaps <=is a non-standard equality to the op. you mean that both
accomplish the same thing...they are just two different ways of writing the
same thing, right?
In math, <=means "is equivalent to".

Steve
Guest
 
Posts: n/a
#8: Nov 9 '07

re: binary and & vs &=



"Darko" <darko.maksimovic@gmail.comwrote in message
news:1194632959.294732.216730@k79g2000hse.googlegr oups.com...
Quote:
On Nov 9, 7:11 pm, "Steve" <no....@example.comwrote:
Quote:
>"Darko" <darko.maksimo...@gmail.comwrote in message
>>
>news:1194624540.774587.257620@o3g2000hsb.googlegr oups.com...
>>
Quote:
On Nov 9, 3:35 pm, joshuajnoble <joshuajno...@gmail.comwrote:
>Is there any difference between doing:
>>
Quote:
>$var & 0x80;
>>
Quote:
>and
>>
Quote:
>$var &= 0x80;
>>
Quote:
>I've seen the second, using the &= in production code, but on my local
>machine it errors out. Any thoughts?
>>
Quote:
$var &= 0x80 <= $var = $var & 0x80
>>
>perhaps <=is a non-standard equality to the op. you mean that both
>accomplish the same thing...they are just two different ways of writing
>the
>same thing, right?
>
In math, <=means "is equivalent to".
right. however, i was considering the question posed by the op...dealing
with hex and bits. he's probably not going to immediately see that you're
saying they're equal.

no big.


joshuajnoble
Guest
 
Posts: n/a
#9: Nov 10 '07

re: binary and & vs &=



Thanks for the help the &= and & is clear to me now. I wasn't getting
an error, it just didn't echo out any value from the &= when I set the
$var to an int value. Thanks again.


On Nov 9, 3:49 pm, "Steve" <no....@example.comwrote:
Quote:
"Darko" <darko.maksimo...@gmail.comwrote in message
>
news:1194632959.294732.216730@k79g2000hse.googlegr oups.com...
>
>
>
Quote:
On Nov 9, 7:11 pm, "Steve" <no....@example.comwrote:
Quote:
"Darko" <darko.maksimo...@gmail.comwrote in message
>
Quote:
Quote:
>news:1194624540.774587.257620@o3g2000hsb.googlegr oups.com...
>
Quote:
Quote:
On Nov 9, 3:35 pm, joshuajnoble <joshuajno...@gmail.comwrote:
Is there any difference between doing:
>
Quote:
Quote:
$var & 0x80;
>
Quote:
Quote:
and
>
Quote:
Quote:
$var &= 0x80;
>
Quote:
Quote:
I've seen the second, using the &= in production code, but on my local
machine it errors out. Any thoughts?
>
Quote:
Quote:
$var &= 0x80 <= $var = $var & 0x80
>
Quote:
Quote:
perhaps <=is a non-standard equality to the op. you mean that both
accomplish the same thing...they are just two different ways of writing
the
same thing, right?
>
Quote:
In math, <=means "is equivalent to".
>
right. however, i was considering the question posed by the op...dealing
with hex and bits. he's probably not going to immediately see that you're
saying they're equal.
>
no big.

Darko
Guest
 
Posts: n/a
#10: Nov 10 '07

re: binary and & vs &=


On Nov 10, 1:12 am, joshuajnoble <joshuajno...@gmail.comwrote:
Quote:
Thanks for the help the &= and & is clear to me now. I wasn't getting
an error, it just didn't echo out any value from the &= when I set the
$var to an int value. Thanks again.
>
On Nov 9, 3:49 pm, "Steve" <no....@example.comwrote:
>
Quote:
"Darko" <darko.maksimo...@gmail.comwrote in message
>
Quote:
news:1194632959.294732.216730@k79g2000hse.googlegr oups.com...
>
Quote:
Quote:
On Nov 9, 7:11 pm, "Steve" <no....@example.comwrote:
>"Darko" <darko.maksimo...@gmail.comwrote in message
>
Quote:
Quote:
>>news:1194624540.774587.257620@o3g2000hsb.googleg roups.com...
>
Quote:
Quote:
On Nov 9, 3:35 pm, joshuajnoble <joshuajno...@gmail.comwrote:
>Is there any difference between doing:
>
Quote:
Quote:
>$var & 0x80;
>
Quote:
Quote:
>and
>
Quote:
Quote:
>$var &= 0x80;
>
Quote:
Quote:
>I've seen the second, using the &= in production code, but on my local
>machine it errors out. Any thoughts?
>
Quote:
Quote:
$var &= 0x80 <= $var = $var & 0x80
>
Quote:
Quote:
>perhaps <=is a non-standard equality to the op. you mean that both
>accomplish the same thing...they are just two different ways of writing
>the
>same thing, right?
>
Quote:
Quote:
In math, <=means "is equivalent to".
>
Quote:
right. however, i was considering the question posed by the op...dealing
with hex and bits. he's probably not going to immediately see that you're
saying they're equal.
>
Quote:
no big.
When people say "Don't do top posts", it means that you should write
your answer
-below- the quotes, not -above-. It eases reading and people stick to
the rule.

Closed Thread