Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

Why do "yes/no" values in Microsoft Access map to -1 and 0?

Writer Andrew Henderson

The use of -1 puzzles me. I would have expected the values to be:

  • NO --> 0
  • YES --> +1

Is there an historical reason behind the use of -1 instead of +1?

4

1 Answer

As discussed on Stack Overflow here, Yes/True values appear in Access as -1 because

  • Yes/No fields in Access mimic bit fields,
  • Integer values in Access are signed, two's complement values,
  • No/False is represented by 0, and
  • the only other two's complement value of a 1-bit number is -1. To illustrate, two's complement numbers can have the following values:

3-bit:

bits integer
---- -------
000 0
001 1
010 2
011 3
100 -4
101 -3
110 -2
111 -1

2-bit:

bits integer
---- -------
00 0
01 1
10 -2
11 -1

1-bit:

bits integer
---- -------
0 0
1 -1

For the integer representation of a bit field (i.e., 1-bit), if 0 is No/False then the only other value available for Yes/True is -1.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy