I know how to work with bits, such as shifts, operators |, &, ^ . In the Internet, they write that they are used for low-level tasks, in engineering and so on.

I usually use ordinary operators like ||, && or and, or and so on. and without them in any way, that is, their purpose is clear. But the purpose of logical bitwise operators is not completely clear to me.

Why do I need them, in which cases they will be useful to me, an ordinary programmer)?

  • For bitmasks , for example - andreymal
  • and, or, not are logical operators. |, &, ^ - can be bitwise operators. For which particular operators are you looking for examples? - jfs
  • for them - |, &, ^, bitwise. - DevOma

1 answer 1

Bitwise operations cost little, in terms of computation. With their help, you can quickly determine if a number is a power of two or is it even. They are also actively used in encryption. https://pas1.ru/bitarithmetic