Skip to content

Latest commit

 

History

History
80 lines (68 loc) · 2.18 KB

File metadata and controls

80 lines (68 loc) · 2.18 KB
title Bitwise Inclusive OR Operator: | | Microsoft Docs
ms.custom
ms.date 11/04/2016
ms.reviewer
ms.suite
ms.technology
cpp-language
ms.tgt_pltfrm
ms.topic language-reference
f1_keywords
bitor
|
dev_langs
C++
helpviewer_keywords
OR operator, bitwise inclusive
bitwise operators, OR operator
inclusive OR operator
| operator
ms.assetid 4c8a6a68-d828-447d-875a-aedb4ce3aa9a
caps.latest.revision 7
author mikeblome
ms.author mblome
manager ghogen
translation.priority.ht
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

Bitwise Inclusive OR Operator: |

Syntax

  
expression   
|  
 expression  
  

Remarks

The bitwise inclusive OR operator (|) compares each bit of its first operand to the corresponding bit of its second operand. If either bit is 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.

Both operands to the bitwise inclusive OR operator must be of integral types. The usual arithmetic conversions covered in Standard Conversions are applied to the operands.

Operator Keyword for |

The bitor operator is the text equivalent of |. There are two ways to access the bitor operator in your programs: include the header file iso646.h, or compile with the /Za (Disable language extensions) compiler option.

Example

// expre_Bitwise_Inclusive_OR_Operator.cpp  
// compile with: /EHsc  
// Demonstrate bitwise inclusive OR  
#include <iostream>  
using namespace std;  
  
int main() {  
   unsigned short a = 0x5555;      // pattern 0101 ...  
   unsigned short b = 0xAAAA;      // pattern 1010 ...  
  
   cout  << hex << ( a | b ) << endl;   // prints "ffff" pattern 1111 ...  
}  

See Also

C++ Built-in Operators, Precedence and Associativity
C Bitwise Operators