1. Home
  2. Computing & Technology
  3. C / C++ / C#

Definition of OR

By David Bolton, About.com

Definition: OR is an operation between two bits. If either bit is set then the result is set. If both are clear, the result is clear. This can be shown as below.
A B --- A OR B
0 0 ----- 0
0 1 ----- 1
1 0 ----- 1
1 1 ----- 1
In C, C++ and C# binary OR is represented by a single pipe character |.

In expressions, OR is represented by the double pipe character || as in

if (a==2) || (a==3) { //.. rest of code
Which means if a equals 2 or a equals 3

Glossary:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Examples:
OR is often used to combine bytes together.
Explore C / C++ / C#
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. C / C++ / C#
  4. Glossary
  5. O
  6. OR - Definition>

©2009 About.com, a part of The New York Times Company.

All rights reserved.