# -1 and 0 for "Yes" and "No" (?)

C

#### croy

It seems with MS Access that it is understood that -1
corresponds with "Yes", and 0 corresponds with "No".

Is that generally true for the database design community as
a whole?

J

#### John W. Vinson

It seems with MS Access that it is understood that -1
corresponds with "Yes", and 0 corresponds with "No".

Is that generally true for the database design community as
a whole?

No. Not even Microsoft is consistant; in SQL/Server a Boolean field is stored
as a Bit, with +1 being TRUE and 0 being FALSE.

I think it's safe now to assert that 0 is FALSE and nonzero is TRUE, but do
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/

D

#### David-W-Fenton

No. Not even Microsoft is consistant; in SQL/Server a Boolean
field is stored as a Bit, with +1 being TRUE and 0 being FALSE.

I think it's safe now to assert that 0 is FALSE and nonzero is
TRUE, but do read the documentation carefully!

If you program on that assumption, your code will be very
cross-compatible with all databases, seems to me. True is really
nothing more than NOT FALSE.

G

#### Gene Wirchenko

If you program on that assumption, your code will be very
cross-compatible with all databases, seems to me. True is really
nothing more than NOT FALSE.

It is a dangerous assumption. NOT can be a bitwise operator on
integers. In two's-complement arithmetic, NOT 1 equals -2, and both
are considered true by the non-zero is true assumption.

If this is a concern, use a boolean type. If you can not do
that, then determine true and false using something like
true=0=0
false=not true
and then use those variable where you need boolean values.

Sincerely,

Gene Wirchenko

D

#### David-W-Fenton

It is a dangerous assumption. NOT can be a bitwise operator
on
integers.

But it's not in VBA, which is what you'd be using in Access.

Of course, it's certainly true that you could be using it in SQL, as
well, but if you're not writing passthroughs, it will be executed by
Jet/ACE, so results will be reliable.
In two's-complement arithmetic, NOT 1 equals -2, and both
are considered true by the non-zero is true assumption.

If this is a concern, use a boolean type. If you can not do
that, then determine true and false using something like
true=0=0
false=not true
and then use those variable where you need boolean values.

I don't think any of this is relevant to any circumstances in which
one would be using Access as one's development platform.

That WAS what we were talking about, no?

G

#### Gene Wirchenko

On 21 May 2011 19:37:22 GMT, "David-W-Fenton"

[snip]
I don't think any of this is relevant to any circumstances in which
one would be using Access as one's development platform.

That WAS what we were talking about, no?

No. OP asked "Is that generally true for the database design
community as a whole?"

Sincerely,

Gene Wirchenko