binary and & vs &=
am 09.11.2007 15:35:18 von joshuajnoble
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 &=
am 09.11.2007 15:42:13 von Steve
"joshuajnoble" wrote in message
news:1194618918.690991.128490@v23g2000prn.googlegroups.com.. .
> Is there any difference between doing:
>
> $var & 0x80;
doesn't not effect the value of $var.
> and
>
> $var &= 0x80;
assigns the result of ($var & 0x80) to $var.
> 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 &=
am 09.11.2007 16:00:31 von luiheidsgoeroe
On Fri, 09 Nov 2007 15:42:13 +0100, Steve wrote:
> "joshuajnoble" wrote in message
> news:1194618918.690991.128490@v23g2000prn.googlegroups.com.. .
>> Is there any difference between doing:
>>
>> $var & 0x80;
>
> doesn't not effect the value of $var.
>
>> and
>>
>> $var &=3D 0x80;
>
> assigns the result of ($var & 0x80) to $var.
>
>> I've seen the second, using the &=3D in production code, but on my lo=
cal
>> 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 &=
am 09.11.2007 16:36:56 von Steve
"Rik Wasmus" wrote in message
news:op.t1i5a5dq5bnjuv@metallium.lan...
On Fri, 09 Nov 2007 15:42:13 +0100, Steve wrote:
> "joshuajnoble" wrote in message
> news:1194618918.690991.128490@v23g2000prn.googlegroups.com.. .
>> Is there any difference between doing:
>>
>> $var & 0x80;
>
> doesn't not effect the value of $var.
>
>> and
>>
>> $var &= 0x80;
>
> assigns the result of ($var & 0x80) to $var.
>
>> 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.
that's all i could figure too...so i had to ask.
Re: binary and & vs &=
am 09.11.2007 17:09:00 von darko
On Nov 9, 3:35 pm, joshuajnoble wrote:
> 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 &=
am 09.11.2007 19:11:42 von Steve
"Darko" wrote in message
news:1194624540.774587.257620@o3g2000hsb.googlegroups.com...
> On Nov 9, 3:35 pm, joshuajnoble wrote:
>> 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 &=
am 09.11.2007 19:29:19 von darko
On Nov 9, 7:11 pm, "Steve" wrote:
> "Darko" wrote in message
>
> news:1194624540.774587.257620@o3g2000hsb.googlegroups.com...
>
> > On Nov 9, 3:35 pm, joshuajnoble wrote:
> >> 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?
In math, <=> means "is equivalent to".
Re: binary and & vs &=
am 09.11.2007 19:49:47 von Steve
"Darko" wrote in message
news:1194632959.294732.216730@k79g2000hse.googlegroups.com.. .
> On Nov 9, 7:11 pm, "Steve" wrote:
>> "Darko" wrote in message
>>
>> news:1194624540.774587.257620@o3g2000hsb.googlegroups.com...
>>
>> > On Nov 9, 3:35 pm, joshuajnoble wrote:
>> >> 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?
>
> 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 &=
am 10.11.2007 01:12:05 von joshuajnoble
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" wrote:
> "Darko" wrote in message
>
> news:1194632959.294732.216730@k79g2000hse.googlegroups.com.. .
>
>
>
> > On Nov 9, 7:11 pm, "Steve" wrote:
> >> "Darko" wrote in message
>
> >>news:1194624540.774587.257620@o3g2000hsb.googlegroups.com. ..
>
> >> > On Nov 9, 3:35 pm, joshuajnoble wrote:
> >> >> 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?
>
> > 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 &=
am 10.11.2007 02:26:12 von darko
On Nov 10, 1:12 am, joshuajnoble wrote:
> 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" wrote:
>
> > "Darko" wrote in message
>
> >news:1194632959.294732.216730@k79g2000hse.googlegroups.com. ..
>
> > > On Nov 9, 7:11 pm, "Steve" wrote:
> > >> "Darko" wrote in message
>
> > >>news:1194624540.774587.257620@o3g2000hsb.googlegroups.com. ..
>
> > >> > On Nov 9, 3:35 pm, joshuajnoble wrote:
> > >> >> 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?
>
> > > 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.
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.