Use of "Bitwise" - Java [closed]

-1

They tell me "to encrypt an int change bit # 3 from 0 to 1 using bitwise", I need an explanation from this operator, I have no idea of its syntax or how to use it ..

    
asked by Shiro 23.08.2017 в 15:19
source

1 answer

3

Good morning,

The Bitwise operators work at the bit level, allowing to change the specific bit values:

Link examples

Example:

We are going to use, for example, the Bitwise operator ~ :

If we have a = ~2 - > a = -3

Explanation:

The operator ~ reverses all the bits of the number you have put behind, in this case the 2 - > 0000 0010

If we invert all the bits of 2 we have the following: 1111 1101 that is -3

I hope it helps you.

    
answered by 23.08.2017 / 15:31
source