binary and & vs &= | | |
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? | | | | 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? | | | | 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 | | | | 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. | | | | 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 | | | | 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? | | | | 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:
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". | | | | 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:
>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. | | | | 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:
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.
| | | | 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:
>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.
> 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. |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,501 network members.
|