324 words
2 minutes
260815_vulkan_bit_shift_explanation
2026-08-15

link#

In Vulkan code, you will often see something like:#

16 << 10

This is a left bit shift. Let’s break it down.

1. << means “shift bits to the left”#

The expression:

16 << 10

means:

Take the binary representation of 16 and move its bits 10 positions to the left.

16 in binary is:

16 = 0000000000010000

Shift left by 10:

0000000000010000
             ↓↓↓↓↓↓↓↓↓↓
0100000000000000

The result is:

16 << 10 = 16384

Mathematically, for positive integers:

x << n = x × 2ⁿ

Therefore:

16 << 10
= 16 × 2¹⁰
= 16 × 1024
= 16384

2. Why does Vulkan code use this?#

A common reason is to express powers-of-two sizes or bit fields clearly.

For example:

#define MAX_SIZE (16 << 10)

means:

16 KiB

because:

16 × 1024 = 16384 bytes

So:

16 << 10

is another way of writing:

16384

or:

16 * 1024

But the bit-shift form emphasizes that the value is based on binary powers of two.


3. Why 10?#

Because:

2¹⁰ = 1024

So:

x << 10

is equivalent to:

x × 1024

For example:

1 << 10  = 1024
2 << 10  = 2048
4 << 10  = 4096
8 << 10  = 8192
16 << 10 = 16384

This is particularly natural for memory-related Vulkan programming because GPUs and Vulkan resources frequently use power-of-two / binary-aligned sizes.


4. Compare with 16 << 20#

You will also frequently see:

16 << 20

Since:

2²⁰ = 1,048,576

we get:

16 << 20
= 16 × 1,048,576
= 16,777,216

That’s 16 MiB.

So:

16 << 10  → 16 KiB
16 << 20  → 16 MiB

assuming the context is measuring bytes.


5. A useful way to read it#

When you see:

16 << 10

you can mentally read it as:

“16 times 2 to the 10th.”

Similarly:

1 << 20

means:

“2 to the 20th”

and:

64 << 10

means:

“64 KiB.”


One important distinction#

Don’t confuse:

16 << 10

with:

16 >> 10

<< moves bits left:

16 << 10 = 16384

while >> moves bits right:

16 >> 10 = 0

for ordinary integer arithmetic, because the 16’s set bit gets shifted away.

In Vulkan code, << is often used for bit masks, flags, alignment values, and binary-sized quantities, so understanding it is very useful when reading Vulkan headers and examples.

260815_vulkan_bit_shift_explanation
https://younghakim7.github.io/blog/posts/260815_vulkan_bit_shift_explanation/
Author
YoungHa
Published at
2026-08-15