Page 1 of 1

Problems with Not

PostPosted: 13 Nov 2007, 06:16
by BrettVsop
I am compiling in Visual Studios C++ Version 6 and have noticed a problem with the not command. It only reverses the significant digits. Is there a way to make the compiler reverse all digits?

I am currently using a effective work around. I have a constant that has all the digits set to one, and I XOR the variable with the constant. I would prefer to use the unary operator however.

Re: Problems with Not

PostPosted: 13 Nov 2007, 07:14
by rjgibert
The bitwise not operator is "~" and must not be confused with the logical not operator "!" which treats the entire value as a boolean. The logical not is not a bitwise operation.

Re: Problems with Not

PostPosted: 13 Nov 2007, 07:37
by Dann Corbit
BrettVsop wrote:I am compiling in Visual Studios C++ Version 6 and have noticed a problem with the not command. It only reverses the significant digits. Is there a way to make the compiler reverse all digits?

I am currently using a effective work around. I have a constant that has all the digits set to one, and I XOR the variable with the constant. I would prefer to use the unary operator however.


Are you using a big enough type to create your mask? Show us the code that is not doing what you think it ought to do.

Re: Problems with Not

PostPosted: 13 Nov 2007, 08:11
by BrettVsop
typedef unsigned __int64 BITBOARD;

const BITBOARD FULLBOARD = 0xFFFFFFFFFFFFFFFF;


rj saw the problem. I wasn't thinking and used the ! statement.

Thanks