Edit: I coded each rank without basing it on the previous rank. I have two macros, RANK_1 and RANK_8, which represent ranks in chess. Code: #macro RANK_1 0xFF #macro RANK_8 RANK_1 << (8 * 7) RANK_1 = 11111111. RANK_8 = RANK_1 shifted left 56 times (so a 11111111 followed by 56 0's) For some reason, I can flip the bits in RANK_1, but I can not flip the bits in RANK_2: bb_string converts the number into a string that is 64 characters long. It is for debugging so I can see which bits are set. Code: show_debug_message(bb_string(RANK_1)); gives me: Code: 0000000000000000000000000000000000000000000000000000000011111111 which is correct. Code: show_debug_message(bb_string(~RANK_1)); gives me: Code: 1111111111111111111111111111111111111111111111111111111100000000 which is correct. When I run the same code for ~RANK_8, every bit is set, which is incorrect. I believe that when the MSB is set, that bit equals -1. I included that when I checked if a bit was set, so I do not think that is the problem. There is a work around by XORing "all_bits_set" with RANK_8, but I really want to understand why the above code is not working. I am new to all of this so any help is appreciated. Also, if there is more code you need to see, let me know. Thank you for reading.