How do you calculate the CPU Affinity Bitmap? I am trying to calculate the bitmap for my 32-core server. I want my instance to use cores 30 and 31.

I know that CPU 0 gets assigned a value of 1, CPU 1 gets assigned a value of 2, CPU 3 gets assigned a value of 4, etc. 

I think this means that CPU 30 would have a value of 1073741824 and CPU 31 would get a value of 2147483648, but 1073741824 + 2147483648 = 3221225472, which is higher than the max value of an int and not acceptable to sp_configure

After 16 CPUs, does it flip to start using negative numbers or something?

I can't use ALTER SERVER CONFIGURATION to do this, because I am on SQL Server 2008.

I can't use the GUI, because all my processes need to be reusable on Server Core instances.

I also want to understand the theory and what I am missing from it!!!
Your binary representation of the mask should be:

1100 0000  0000 0000  0000 0000  0000 0000


Converting that to an unsigned 32-bit integer would equate to your original calculation:  3221225472.

But the affinity mask tasked a signed 32-bit value.  In that case, the binary to signed 32-bit value would be:  -1073741824.

Same bits, just different interpretation/conversion (signed vs. unsigned).


  I can't use the GUI, because all my processes need to be reusable on Server Core instances.


As an aside, you can and should use SSMS remotely, so the fact that you could have target database servers on a server core OS shouldn't prevent you from remotely using a GUI (like SSMS).  On that same note, I always prefer T-SQL at the very least for reusability and for documentation purposes, if nothing more than just knowing exactly what is happening when you do something with no GUI tricks/abstractions/assumptions.