473,508 Members | 2,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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?

Nov 9 '07 #1
9 1279

"joshuajnoble" <jo**********@gmail.comwrote in message
news:11**********************@v23g2000prn.googlegr oups.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?
Nov 9 '07 #2
On Fri, 09 Nov 2007 15:42:13 +0100, Steve <no****@example.comwrote:
"joshuajnoble" <jo**********@gmail.comwrote in message
news:11**********************@v23g2000prn.googlegr oups.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.
--
Rik Wasmus
Nov 9 '07 #3

"Rik Wasmus" <lu************@hotmail.comwrote in message
news:op***************@metallium.lan...
On Fri, 09 Nov 2007 15:42:13 +0100, Steve <no****@example.comwrote:
"joshuajnoble" <jo**********@gmail.comwrote in message
news:11**********************@v23g2000prn.googlegr oups.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.
Nov 9 '07 #4
On Nov 9, 3:35 pm, joshuajnoble <joshuajno...@gmail.comwrote:
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

Nov 9 '07 #5

"Darko" <da**************@gmail.comwrote in message
news:11**********************@o3g2000hsb.googlegro ups.com...
On Nov 9, 3:35 pm, joshuajnoble <joshuajno...@gmail.comwrote:
>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?
Nov 9 '07 #6
On Nov 9, 7:11 pm, "Steve" <no....@example.comwrote:
"Darko" <darko.maksimo...@gmail.comwrote in message

news:11**********************@o3g2000hsb.googlegro ups.com...
On Nov 9, 3:35 pm, joshuajnoble <joshuajno...@gmail.comwrote:
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".

Nov 9 '07 #7

"Darko" <da**************@gmail.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
On Nov 9, 7:11 pm, "Steve" <no....@example.comwrote:
>"Darko" <darko.maksimo...@gmail.comwrote in message

news:11**********************@o3g2000hsb.googlegr oups.com...
On Nov 9, 3:35 pm, joshuajnoble <joshuajno...@gmail.comwrote:
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.
Nov 9 '07 #8

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:
"Darko" <darko.maksimo...@gmail.comwrote in message

news:11**********************@k79g2000hse.googlegr oups.com...
On Nov 9, 7:11 pm, "Steve" <no....@example.comwrote:
"Darko" <darko.maksimo...@gmail.comwrote in message
>news:11**********************@o3g2000hsb.googlegr oups.com...
On Nov 9, 3:35 pm, joshuajnoble <joshuajno...@gmail.comwrote:
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.

Nov 10 '07 #9
On Nov 10, 1:12 am, joshuajnoble <joshuajno...@gmail.comwrote:
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:
"Darko" <darko.maksimo...@gmail.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
On Nov 9, 7:11 pm, "Steve" <no....@example.comwrote:
>"Darko" <darko.maksimo...@gmail.comwrote in message
>>news:11**********************@o3g2000hsb.googleg roups.com...
On Nov 9, 3:35 pm, joshuajnoble <joshuajno...@gmail.comwrote:
>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.

Nov 10 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2760
by: Rune Froysa | last post by:
Trying something like:: import xmlrpclib svr = xmlrpclib.Server("http://127.0.0.1:8000") svr.test("\x1btest") Failes on the server with:: xml.parsers.expat.ExpatError: not well-formed (invalid...
2
3639
by: katiki | last post by:
Hi all, I suppose it's a frequent post, but I would like to include a binary data (iomage in fact) into xml files (generated by our application). Custiomer does not want the image to be an...
11
2541
by: Steve | last post by:
Hi, i know this is an old question (sorry) but its a different problem, i need to write a binary file as follows 00000011 00000000 00000000 00000101 00000000 11111111
0
380
by: gauravkhanna | last post by:
Hi All I need some help for the below problem: Scenario We need to send large binary files (audio file of about 10 MB or so) from the client machine (.Net Windows based application, located...
1
1478
by: Agnes | last post by:
my form got over 30 textbox, as I addnew() and update the record, it said "string & binary data unable trunctated" and that record didn't save in database I used Try catch to check the error, It...
3
8516
by: Billy Smith | last post by:
I'm trying to write a little utility that will write some binary data to a file via a javascript and Windows Script Host under Windows XP. The only way to do this that I can find is to convert...
4
31356
by: muthu | last post by:
In the following code it gives the error "error: invalid operands to binary &" Why it is happening #include <signal.h> #include <errno.h> #define SIGBAD(signo) ((signo) <= 0 || (signo) >=...
4
2342
by: joe | last post by:
how to resize an upload image and then change to binary & insert to db
6
7824
by: jjhall | last post by:
I need to open and read a file that has a combined ascii and binary format. Don't ask me why it is this way; I think it is kind of stupid, but I didn't write the program that generated the file. ...
1
2891
by: KWSW | last post by:
Got a question about reading and writing binary files. I know that to write a value(integer) to a binary file I can use the fileoutputstream to do it. try { // Create an output...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5049
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.