# What does double less-than sign do?

**URL:** https://discussions.unity.com/t/what-does-double-less-than-sign-do/96632
**Category:** Questions & Answers
**Created:** [February 19, 2014, 7:33pm UTC](https://discussions.unity.com/t/what-does-double-less-than-sign-do/96632 "2014-02-19T19:33:21Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![OTPABA](https://avatars.discourse-cdn.com/v4/letter/o/ed8c4c/32.png) [@OTPABA](https://discussions.unity.com/u/OTPABA)
#### Post date: [February 19, 2014, 7:33pm UTC](https://discussions.unity.com/t/what-does-double-less-than-sign-do/96632/1 "2014-02-19T19:33:21Z")

</div>

I was looking through the code of Unity sample game and found this piece of code:

```
grounded = Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Ground"));

```

So i wondered what does “\<\<” this sign do and how does this line return bool value?

---

<div class="post-metadata">

### Author: ![steakpinball\_1](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@steakpinball\_1](https://discussions.unity.com/u/steakpinball_1)
#### Post date: [February 19, 2014, 11:27pm UTC](https://discussions.unity.com/t/what-does-double-less-than-sign-do/96632/2 "2014-02-19T23:27:51Z")

</div>

`<<` is the left shift operator. It moves the bits in the first operand left by the number of places in the second operand.

Example. `1 << 2` returns 4. Let’s look at the bits to see why. Integer 1 in binary is `000000001`. We tell the bits to move left two places producing binary `000000100`. That represents the integer 4.

> **[Bitwise and shift operators - perform boolean (AND, NOT, OR, XOR) and shift...](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/bitwise-and-shift-operators?redirectedfrom=MSDN#left-shift-operator-)**
>
> Learn about C# operators that perform bitwise logical (AND - \`&\`, NOT - \`~\`, OR - \`|\`, XOR - \`^\`) or shift operations( \`\<\<\`, and \`\>\>\`) with operands of integral types.

* * *

In Unity layers are stored as integers. User layer 6 is actually the number 6. [LayerMask.NameToLayer](https://docs.unity3d.com/Documentation/ScriptReference/LayerMask.NameToLayer.html) returns the integer of the layer for the given name. If your “Ground” layer is layer 8, `1 << LayerMask.NameToLayer("Ground"))` will return binary `100000000` which is the integer 256.

* * *

The [Physics2D.Linecast](http://docs.unity3d.com/Documentation/ScriptReference/Physics.Linecast.html) third parameter is a bit mask. Each bit in the integer corresponds to a layer. The rightmost bit corresponds to layer 0. The next bit from the right corresponds to layer 1. The next bit from the right corresponds to layer 2. The next bit from the right corresponds to layer 3, and so forth up to layer 32.

```
Layer 9 8 7 6 5 4 3 2 1 0
Bits 0 0 0 0 0 0 0 0 0 0

```

Each bit can be either a one or a zero. A 1 means to match that layer, a zero means to not match. Using a layer mask of 1 (Binary `000000001` (`1 << 0`)) tells Physics2D.Linecast to only hit colliders on layer 0. Using a layer mask of 256 (Binary `100000000` (`1 << 8`)) tells Physics2D.Linecast to only hit colliders on layer 8. If Physics2D.Linecast hits a collider on the specified layers it returns `true` otherwise it returns `false`.
