# What is the | (the bitwise OR operator) used for?

**URL:** <https://forum.kirupa.com/t/what-is-the-the-bitwise-or-operator-used-for/191678>\
**Category:** flash\
**Created:** [June 22, 2006, 7:26am UTC](https://forum.kirupa.com/t/what-is-the-the-bitwise-or-operator-used-for/191678 "2006-06-22T07:26:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![geebee](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@geebee](https://forum.kirupa.com/u/geebee)\
**Post date:** [June 22, 2006, 7:26am UTC](https://forum.kirupa.com/t/what-is-the-the-bitwise-or-operator-used-for/191678/1 "2006-06-22T07:26:59Z")

</div>

Greetings everyone!

Working my way through the book “Flash MX 2004 games most wanted” from Friend of Ed.  
The book assumes a bit more AS knowledge than I have atm so I’m using a lot of time checking every bit of code - making sure I know what is going on on each line. In one of the program codes (one that makes a tile-based gameboard) I’ve come across the bitwise OR operator written in AS as |. What is the use of this operator? In the Flash 8 AS helpfile it says:

expression1 | expression2

Converts expression1 and expression2 to 32-bit unsigned integers, and returns a 1 in each bit position where the corresponding bits of either expression1 or expression2 are 1. Floating-point numbers are converted to integers by discarding any digits after the decimal point. The result is a new 32-bit integer.

They also give the following code example:

// 15 decimal = 1111 binary  
var x:Number = 15;  
// 9 decimal = 1001 binary  
var y:Number = 9;  
// 1111 | 1001 = 1111  
trace(x | y); // returns 15 decimal (1111 binary)

Problem is I can’t wrap my head around the logic of this operator - example: why does the code above output 15 and not something else? Basically my question is this: how does | work? And how is it usefull to me when writing code?

Any hints to this are more than welcome!
