Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
&= and-assignment
|= or-assignment
^ = xor-assignment
<<= left-shift-assignment
>>= right-shift-assignment -
jchw11028yLogical XOR is just the same as not equal.
true != true : false
true != false : true
false != true : true
false != false : false
So for booleans, a ^ b is equivalent to a != b. Though there's no compound assign for not equal, so it is very slightly more convenient in some cases. -
donuts236728y@bkwilliams bit operators... i've never used them.... and i dont know how or why i need them... am i a bad dev?
-
@billgates it's a hold over from C but now they are used to make jr devs ask questions during code review.
-
jchw11028y@bkwilliams @billgates Well they are Definitely still used and useful for many more advanced things. If you want to implement a binary format of any kind they are everything short of necessary. A good, simple example would be implementing compression like lz4.
-
@billgates @bkwilliams @jchw They are incredibly useful for competitive programing as well. Also good in optimizing some stuff, making them take logarithmic time (via comparing binary representation of the start and end and doing computations on those) vs linear (via going through all numbers).
-
@BingBangTheory cool, however my scope is usually higher so they are not leveraged.
-
Bro, are you kidding me? That's one of the first things I read in my freshman year syllabus.
-
Salmakis6737yim pretty sure the guys that said "i never used bitwise" had used thrm without even knowing about it. example with flag settings with |
Related Rants
What?!?
There is an ^= operator in Java for booleans. I have been programming in Java for 4 years now and never knew this. Like b ^= true will flip b.
Mind blown; this is the greatest thing ever
undefined
java