Bentley
Member
I am (attempting) to work with bitboards. Does anyone know the reason the most significant bit, when on, equals -1 instead of 1.
Ex:
It's workable, as I can just check for -1 or 1 to see if a bit is on. But I feel like I'm doing something wrong as I've never seen a check for a -1 bit on any of the "bit tricks" I've seen.
I am relatively new to all this. Anyone know what's going on?
Ex:
Code:
// A 64 bit int.
// Every bit is on except the first 4 bits on the LSB / left side
bb = 0xFFFFFFFFFFFFFFF0;
show_message(sign(bb & (1 < 0))); // Got 0 as expected
show_message(sign(bb & (1 << 62))); // Got 1 as expected
show_message(sign(bb & (1 << 63))); // Got -1.
I am relatively new to all this. Anyone know what's going on?