Visual C++ - Bitwise or: |
Bitwise AND or with another name setting to 1. it get the setting to 1 name after logical or operator: just in case it's the result false if both inputs are false, in all other cases the result is true. it transferred to the variables means that only those bits remain 0 where both inputs was 0 otherwise it set to 1. this property can be used for example to setting up specific bits: taking one example, we have one variable in which the 5th, 6th bits we want to set up 1. We need a number where 5th, 6th bit are set to 1 and all other bits are 0: 00110000 in hexadecimal form 30 and decimal 48. we perform a bitwise OR operation, above the number 48 and over the variable, the result will be set the 5th, 6th bits to 1 and other bits remain without changes (xx11xxxx)|
Description
par1 | par2
Input
- par1 - Any integer
- par2 - Any integer
Output
- Result - Integers
Examples
Visual C++ .NET
Bitwise or the possible of use:x = 1 | 2; // x = 3
y = 0xa | 5; // y = F
z = 0xf0 | (x | y); // z = FF
Visual C++ .NET
Even one example in what situations we can use the operation bitwise or:i | j
0xff | k
64 | (i | k)
Visual C++ .NET
Other pieces of example codes:0x01 | 0x02
You can find it in the following collections: bitwise operators
Bitwise or in another programming language:
Differences to: