#Operatore

1 messages · Page 1 of 1 (latest)

hidden mural
#

Hello everyone ,
I have the question that when ,why we need for bitwize operator how much we should know about them

frigid haloBOT
#

<@&987246399047479336> please have a look, thanks.

hidden mural
#

second i cant find the Java-helper etc in this channel

eager dew
#

especially in java, they have more niche uses

#

one usage, for example, is a chess board represantation

#

you have 1 long, which is 64 bits(the same number as the squares on one chess board), and each piece has one long per color, so for example the white king has a long, and the bit that corresponds to where it is at on the board, is flipped, so if he was on the right/bottom most square(h8), you would do something like this kingLong & 1, if it is 1, he is there, if not, he isnt

#

that is one common usage of there operators, it is called using a bitmask, to check if a certain bit is flipped or not

#

for a java dev, you should know what they do, in case you see them in code, but they arent used often in java from my experience

#

I am not an expert on this though so you should wait for someone elses opinion as well

wintry lagoon
sullen grail
#

some operators are used so often that almost every language has them. These operators help us make decisions in our code.

One common example is the AND operator. It is used when we want a condition to work only if all given conditions are true. If even one condition is false, the whole condition becomes false.

For example, imagine a program that should allow a user to log in only if:

the username is correct AND

the password is correct

Here, both conditions must be true for the program to continue.

That’s why these operators are very important. A beginner should learn them properly and understand when and how to use them, because they are used in conditions in almost every program.

eager dew
#

that different

#

that's for booleans

#

&& and ||

slate mango
#

Bitwise operators aren't used often, but they can be useful in particular situations. I would definitely learn how to use them. You won't use them frequently, but you'll find uses here and there which can make them extremely useful and helpful.

fallen steeple
#

They have lots of usecases actually, try reading any modern binary file format without these

#

Lots of uses in hashing, compression etc

#
// Step 6: Final mix (avalanche)
acc = acc ^ (acc >>> 33);
acc = acc * PRIME64_2;
acc = acc ^ (acc >>> 29);
acc = acc * PRIME64_3;
acc = acc ^ (acc >>> 32);
``` Like this part in my implementation of xxhash64
#

But then again, I live and breathe these things, so ymmv

hidden mural
#

but the question now is t that how much i worked and invest time in them