473,395 Members | 1,675 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Is it ok to have a boolean field in that uses values 0 for False and -1 for True?

Hi,

Stupid Question:
I have a boolean field in an Access table that uses values 0 for False and -1 for True

Is this normal? Shouldn't it be 0 and 1?

I know this isn't really the right place for a question like this but I really like this site!

Thanks,
- MB
Feb 10 '11 #1

✓ answered by Rabbit

Here's why. The Access boolean data type is actually 2 bytes. So it is basically an integer. And VBA doesn't have an unsigned version of integers. So in binary, true is "1000000000000000" while false is "0000000000000000". In signed variables, the leftmost bit, signifies the sign. In the case of signed integers, that leftmost 1 means it's a negative number. And the rest of the zeroes means it's the first negative number, ie -1.

In most other implementations, a boolean is a byte with true being "00000001" and false being "00000000".

5 2020
RuralGuy
375 Expert 256MB
0 and -1 is exactly right!
Feb 10 '11 #2
Thanks Doomguy!

It seemed weird to me because everywhere I looked online made reference to 0 and 1 as the values, couldn't find anything about -1.
Feb 10 '11 #3
Rabbit
12,516 Expert Mod 8TB
Here's why. The Access boolean data type is actually 2 bytes. So it is basically an integer. And VBA doesn't have an unsigned version of integers. So in binary, true is "1000000000000000" while false is "0000000000000000". In signed variables, the leftmost bit, signifies the sign. In the case of signed integers, that leftmost 1 means it's a negative number. And the rest of the zeroes means it's the first negative number, ie -1.

In most other implementations, a boolean is a byte with true being "00000001" and false being "00000000".
Feb 10 '11 #4
RuralGuy
375 Expert 256MB
Actually any non zero value would work for a false in VBA unless you use the Boolean NOT. Then the -1 makes all kinds of sense since the bits are 1's it negates quite nicely.
Feb 10 '11 #5
Rabbit
12,516 Expert Mod 8TB
When evaluating true or false that is the case. But when assigning true or false, it's a constant that it assigns.
Feb 10 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Dale | last post by:
Stupid question, but since I can't find it in the VS help... I need to create a structure and pass it to a Win32 API function. How many bytes is a C BOOLEAN? And is it the same size as a C#...
7
by: Ottar | last post by:
I've made a program sorting incomming mail in public folder. The function runs every minute by using the form.timer event. In Access XP it runs for weeks, no problem. Access 2003 runs the same...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
55
by: AnandaSim | last post by:
I just had a google through this NG but have not seen mention of Erik Rucker's blog entry and the new Jet: http://blogs.msdn.com/access/archive/2005/10/05/477549.aspx mentioned by Mike...
1
by: Microsoft News | last post by:
I have a web server sitting on computer 1, (QA1). Out on the network on my main server I have a folder with a zip file in it. All I want is for the web services that are on the web server to pick...
1
by: cpajoe2001 | last post by:
I am having an issue and after searching around online for a day and half now and finding others with the same problem but yet no solution to my issue I am looking for help. What i have is ServerA...
1
by: Chris | last post by:
Hi, I'm using the following code DataTable tables = ((OleDbConnection)oleconn).GetOleDbSchemaTable( OleDbSchemaGuid.Tables, new object { null, null, null, "TABLE" }); foreach (DataRow r in...
8
by: Jeremy Ames | last post by:
I am trying to move an application from my system to a new test system. I really should have tried an easier program first, but I didn't really have a chance. My application was originally written in...
1
by: gihan | last post by:
Hi, I have a problem accessing remote webservice from my asp code. Instead of returning results, it returns list of web methods it has. Wonder where i'm doing wrong. Also note that, this is a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.