1

I have been making a game using Sprite Kit and its physics and met this struct in tutorial:

struct PhysicsCategory
{
    static let None: UInt32 = 0
    static let All: UInt32 = UInt32.max
    static let Player: UInt32 = 0b10
    static let Obstacle: UInt32 = 0b11
}

Can anyone tell me what means 0b01 etc. and how to make a new constant here?

Eduard
  • 516
  • 1
  • 4
  • 17

1 Answers1

2

It's hexa, that is, a 16-base number

0b11 in hexa is

0 * 16^3 + 11 * 16^2 + 1 * 16^1 + 1 * 16^0 = 2816 + 16 + 1 = 2833

In hexa, numbers like 10, 11, 12, 13, 14, 15 are represented by letters, such as a, b, c, d, e, f

Look here for more info.

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175