Why is "Yes" a value of -1 in MS Access database? Why is "Yes" a value of -1 in MS Access database? sql sql

Why is "Yes" a value of -1 in MS Access database?


The binary representation of False is 0000000000000000 (how many bits are used depends on the implementation). If you perform a binary NOT operation on it, it will be changed to 1111111111111111, i.e. True, but this is the binary representation of the signed integer -1.

A bit of 1 at the most significant position signals a negative number for signed numbers. Changing the sign of a number happens by inverting all the bits and adding 1. This is called the Two's complement.

Let us change the sign of 1111111111111111. First invert; we get:0000000000000000

Then add one:0000000000000001, this is 1.

This is the proof that 1111111111111111 was the binary representation of -1.


UPDATE

Also, when comparing these values do not compare

x = -1

or

x = 1

instead, do compare

x <> 0

this always gives the correct result, independently of the convention used. Most implementations treat any value unequal zero as True.


"Yes" is -1 because it isn't anything else.

When dealing with Microsoft products, especially one as old as Access, don't assume that there is a good reason for any design choice.