Z
Z
ZhGhost2019-03-21 03:21:26
C++ / C#
ZhGhost, 2019-03-21 03:21:26

c++ variable value?

Hello, banal question, what does
lek = (value | value); what does | mean? Logical AND? And what will be the value of the variable?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel, 2019-03-21
@HEKOT

"|" -- This is a bitwise "OR". The value of the variable will be value.

A
Anatoly, 2019-03-21
@AnatolTh

This is a bitwise (bitwise) inclusive OR | .

a = 15 | 9; // 15 т.к. 1111 | 1001 = 1111
b = 8 | 10; // 10 т.к 1000 | 1010 = 1010
b = 10 | 13; // 15 т.к. 1010 | 1101 = 1111

Not to be confused with the logical operation OR || .
Not to be confused with bitwise (bitwise) XOR ^ .
a = 15 ^ 9; // 6 т.к. 1111 ^ 1001 = 0110
b = 8 ^ 10; // 2 т.к 1000 ^ 1010 = 0010
b = 10 ^ 13; // 7 т.к. 1010 ^ 1101 = 0111

In your case, lek will be value.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question