Binary operators in Access 97

Gibbo

New member
Local time
Today, 10:32
Joined
Jan 6, 2006
Messages
9
I am trying to store binary values (as decimal long integers) and then use bitwise comparisons to update the values. MS help suggest that the standard logical operators (And or etc) can do bitwise comparison as opposed to comparing boolean logical values for expressions; but I have found no way of making this work.

Is this possible? Any ideas. Doing it mechanically, by splitting the decimal into the relevant parts for any bit is very tedious!

Gibbo
 
G’day Gibbo and welcome to the site.

I’m not really sure what you mean by ‘decimal long integers’.

A long integer is a 32 bit binary number that is displayed as decimal using two’s complement conversion.

Can you give an exact example of the problem you are having with the logical operators?

We would need to know if required in SQL or VBA and the data type of table storage.

Edit.
Wrong forum to post this type of question. Maybe a moderator could move it.


Regards,
Chris.
 
Last edited:
Thanks for your reply. I suspected that I might be in the wrong forum, but I have never used one of these sites before and I am still getting the hang of it.

I have a table which contains a field called Scenario. The field type is number and the field size is Long Integer. The default is set to 32767, being 2^15-1.
The concept is to allow the records to be included in any of 15 scenarios, with the default being "all". Thus the value is a binary coding of the scenarios in which the record is included.

To test for inclusion, I currently use (int([scenario]/2^n) mod 2 =1 to check a record is the nth scenario; but I feel that it would be neater to use [scenario] and 2^n =2^n ( which is what I would expect a binary comparison to do). However, this always returns true unless one of the values is zero. The test would be performed by a query, either stored or constructed as SQL in a module.

There are other processes which are more complicated which I think could be simplified. The must obvious is to clone one scenario to another by copying one bit in the scenario value in each record to another bit.

Any ideas?
 
G’day Gibbo.

Well Access SQL doesn’t support bit-wise logical operators but the small attachment may get you started on a workaround.

As you will see, most of the work is done in VBA but once it is correct is makes for easier processing within the queries.

Anyway I hope that goes part of the way to handle bit-wise logical operators in queries.

Regards,
Chris.
 

Attachments

Users who are viewing this thread

Back
Top Bottom