473,660 Members | 2,459 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 1284

"joshuajnob le" <jo**********@g mail.comwrote in message
news:11******** **************@ v23g2000prn.goo glegroups.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:
"joshuajnob le" <jo**********@g mail.comwrote in message
news:11******** **************@ v23g2000prn.goo glegroups.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.comwro te in message
news:op******** *******@metalli um.lan...
On Fri, 09 Nov 2007 15:42:13 +0100, Steve <no****@example .comwrote:
"joshuajnob le" <jo**********@g mail.comwrote in message
news:11******** **************@ v23g2000prn.goo glegroups.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...@g mail.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.comwro te in message
news:11******** **************@ o3g2000hsb.goog legroups.com...
On Nov 9, 3:35 pm, joshuajnoble <joshuajno...@g mail.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.comwro te in message

news:11******** **************@ o3g2000hsb.goog legroups.com...
On Nov 9, 3:35 pm, joshuajnoble <joshuajno...@g mail.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.comwro te in message
news:11******** **************@ k79g2000hse.goo glegroups.com.. .
On Nov 9, 7:11 pm, "Steve" <no....@example .comwrote:
>"Darko" <darko.maksimo. ..@gmail.comwro te in message

news:11******* *************** @o3g2000hsb.goo glegroups.com.. .
On Nov 9, 3:35 pm, joshuajnoble <joshuajno...@g mail.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.comwro te in message

news:11******** **************@ k79g2000hse.goo glegroups.com.. .
On Nov 9, 7:11 pm, "Steve" <no....@example .comwrote:
"Darko" <darko.maksimo. ..@gmail.comwro te in message
>news:11******* *************** @o3g2000hsb.goo glegroups.com.. .
On Nov 9, 3:35 pm, joshuajnoble <joshuajno...@g mail.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...@g mail.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.comwro te in message
news:11******** **************@ k79g2000hse.goo glegroups.com.. .
On Nov 9, 7:11 pm, "Steve" <no....@example .comwrote:
>"Darko" <darko.maksimo. ..@gmail.comwro te in message
>>news:11****** *************** *@o3g2000hsb.go oglegroups.com. ..
On Nov 9, 3:35 pm, joshuajnoble <joshuajno...@g mail.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
2778
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 token) (Smaller test-case: xmlrpclib.loads(xmlrpclib.dumps(('\x1btest',))))
2
3651
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 external files I'm using xerces c++ toolkit, I know there are some usefull classes to achieve that, but I've no sample code at all !
11
2565
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 outside the home network) to the Web Server and then retrieve the file back from the web server to the client.
1
1495
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 can't indicate which field got such error ? Can anyone be kind to teach me how to debug ? Thanks in advance -- ..
3
8524
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 the binary data to text via String.fromCharCode() function and then write to the file with TextStream.Write(). But that function gives an "invalid parameter" error message when I try to write some ASCII codes to the file. I could understand if...
4
31379
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) >= NSIG) /* <signal.husually defines NSIG to include signal number 0 */
4
2354
by: joe | last post by:
how to resize an upload image and then change to binary & insert to db
6
7839
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. Anyway, there is a short header that is written in ascii, then the data is in binary. I have tried opening the file in ascii format first with ifstream data("filename", ios::in); Then I read to a buffer until I reach the end of the header. ...
1
2902
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 stream to the file. FileOutputStream file_output = new FileOutputStream (outFile); //for(int i = 0; i < cInt.length; i++)
0
8341
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8542
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6181
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2760
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 we have to send another system
2
1984
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1740
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.