Please explain uint32_t and 0x1 << 0 in Apple SpriteKit sample code

ios, operators, sprite-kit

Solution

`<<` is bitwise left shift (multiply by 2) operator.

`<< 0` is the same as `*1`

So equivalent statement would be:

static const uint32_t missileCategory  =  0x1;

I wrote more on this here.

For example:

`0x1 << 4` would return `0x10`.

Looking at it binary:

00000001 << 4 = 00010000

Decimaly speaking this would mean `1 * 2 * 2 * 2 * 2` or `1 * 2^4`

And since this is `uint32_t` value it would actualy be

0x00000010

Problem

I found a couple of lines in apples sample codes for SpriteKit ``` static const uint32_t missileCategory = 0x1 << 0; ``` I know what `static const` is but what is an `uint32_t` and what does `0x1 << 0` mean? is it some sort of hex?

Original source

Related problems