Convert between CPU core lists and processor affinity masks in decimal, hexadecimal, and binary. Useful for Windows start /affinity, game launch options, scripting, and troubleshooting performance.
What Is an Affinity Mask?
An affinity mask is a bitmask used by an operating system to define which logical CPU cores a process is allowed to run on. Each bit position maps to a core index: bit 0 is core 0, bit 1 is core 1, and so on. A bit value of 1 means “allowed,” and 0 means “not allowed.”
For example, if you allow cores 0, 1, and 3, your bit pattern is 1011 (reading right-to-left by bit index), which equals decimal 11 and hexadecimal 0xB.
Why Use CPU Affinity?
- Stability testing: Restrict an app to specific cores to reproduce behavior.
- Performance tuning: Reserve cores for streaming, encoding, or background tasks.
- Legacy software compatibility: Some older apps work better with fewer cores.
- Benchmark control: Keep tests consistent across repeated runs.
How This Calculator Works
Cores → Mask
When you enter a list such as 0,2,4-5, the calculator sets those bits to 1 and everything else to 0. The mask is then shown in decimal, hex, and binary.
Formula:
mask = Σ (2^coreIndex) for each selected core
Mask → Cores
When you enter a mask like 0x3C, the calculator inspects each bit and returns the matching core list. If you provide total logical CPUs, it also checks for overflow beyond that limit.
Quick Examples
- Cores 0-3 → binary 1111 → decimal 15 → hex 0xF
- Cores 2-5 → binary 111100 → decimal 60 → hex 0x3C
- Mask 170 → binary 10101010 → cores 1,3,5,7
Windows Command Usage
In Windows, you can launch a process with an affinity mask using:
start /affinity <hexMask> app.exe
If you want cores 0-3 only, use hex mask F:
start /affinity F myapp.exe
Best Practices
- Start with a small change (for example, pin to half the cores) and compare results.
- Avoid over-constraining heavily threaded applications.
- Remember that affinity is not priority; they solve different scheduling problems.
- Document your settings so you can roll back quickly.
Common Mistakes
- Confusing physical cores with logical threads.
- Using decimal when a command expects hexadecimal.
- Forgetting that core numbering usually starts at 0, not 1.
- Applying masks from one machine to another without checking CPU topology.
Final Takeaway
An affinity mask is a simple but powerful control for CPU scheduling. Whether you are tuning a workstation, reducing stutter in a specific app, or testing repeatable workloads, accurate mask conversion saves time and avoids mistakes. Use the calculator above to switch instantly between core selections and mask formats.