473,473 Members | 1,604 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Bitwise check 'attributes record' in database

3 New Member
Hi all,

I want to create rows in a table which id's are 1 - 2 -4 - 8 - 16 - 32 etc.

0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8

So I want to use a Bit mask?

Since I'm a complete noob when it comes to bitwise comparison I want to know if I can use this to accomplish what I want.

I have a table e.g. Table A with food items (steak, tuna, meat balls, etc) and I want a table B (with child records in table C) with attributes which I can add to the food items in Table A.

For instance I want to have a record "TEMPERATURE" in table B. This record has child records "MEDIUM - RARE - WELL DONE".

Another record "SAUCE" has "WHISKEY - MUSHROOM - BLUE CHEESE - ETC"

And "SIDE ORDERS" has "BAKED POTATOES - FRENCHFRIES - ETC"

In the main table A with food items I want an integer field which values are built depending on the records in Table B which are relevant for the product.

If you can still follow me, steak for instance needs to have TEMPERATURE, SAUCE & SIDE ORDERS as attributes and Meat Balls only needs SAUCE & SIDE ORDERS.

I want to fill the Bitwise ID field in the RowOrdersUpdatedEventHandler, if it's value is 32 for instance, how do I change it to the next ^2 value?

Am I limited to let's say a maximum of 32 items if I want to solve this bitwise or is there a better way to do this?

Any help is much appreciated!

Best regards,
Mike
Nov 26 '07 #1
3 1381
Killer42
8,435 Recognized Expert Expert
What version of VB are you using?
What do you mean about going to the next power of 2? To go from 32 to 64, you just multiply by two.
To allow more bits, you should be able to use Long instead of Integer.
As to whether it's good or bad, I guess that's largely subjective. If it works, it works. One alternative might be to use a string/text field with characters rather than bits. Less compact, but perhaps simpler to work with.
Nov 28 '07 #2
Mike Dol
3 New Member
What version of VB are you using?
What do you mean about going to the next power of 2? To go from 32 to 64, you just multiply by two.
To allow more bits, you should be able to use Long instead of Integer.
As to whether it's good or bad, I guess that's largely subjective. If it works, it works. One alternative might be to use a string/text field with characters rather than bits. Less compact, but perhaps simpler to work with.
Sorry for the delay, I use VS2005. I decided to use a parent / child table to solve this problem, I'll try the bitwise solution next time when there are not that many combinations needed.
You were absolutely right I just had to double the integer / long rowID got to keep my thinking straight...

Thanks for your help!

Mike
Dec 16 '07 #3
Killer42
8,435 Recognized Expert Expert
Sorry for the delay, I use VS2005. I decided to use a parent / child table to solve this problem, I'll try the bitwise solution next time when there are not that many combinations needed.
You were absolutely right I just had to double the integer / long rowID got to keep my thinking straight...

Thanks for your help!
Oh well, glad to hear you got things working, anyway. :)
Dec 16 '07 #4

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

Similar topics

4
by: Mike Jansen | last post by:
Does anyone know why if I create a complexType based off another complexType using xsd:extension the attributes don't seem to be inherited? Is this a bug/non-implementation in the .NET Schema...
2
by: Steve Summit | last post by:
-----BEGIN PGP SIGNED MESSAGE----- It's often explained that the reason for some of the imprecision in C's definition is so that C can be implemented on different kinds of machines -- say, those...
2
by: Mark Rae | last post by:
Hi, This isn't *specifically* an ASP.NET question, so I've also posted it in the ADO.NET group - however, it's not too far off-topic... Imagine a SQL Server 2005 database with a table with an...
3
by: Jay Ruyle | last post by:
I'm trying to figure out a way to list several items in a listbox and let the user select any number of items in the listbox. I have tried to code in the items as bitwise items but all it stores...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.