Questions tagged [bitwise-comparison]

The tag has no usage guidance, but it has a tag wiki.

Filter by
Sorted by
Tagged with
1
vote
2answers
55 views

How to convert an integer that was the end result of a bitwise OR to a table of the individual integers that the bitwise OR was applied against?

How can I convert the final integer of a bitwise OR back to it's original set of integers that the bitwise OR operation was applied to? For example if I have the following set of bit values: {0, 1, 2,...
1
vote
1answer
107 views

Using a 512 bit binary column as a bit field

I'm designing a table to keep track of a value that has to represent the on-off setting of several hundred states. I would expand this to 512, to give room for future growth and be a power of two. So ...
5
votes
2answers
145 views

MySQL when a = 0, b = 0, but a <> b (binary)

Any idea of why this is so, CREATE TABLE f AS SELECT b'000000001' AS a, x'01' AS b; This creates two columns of `a` varbinary(2) NOT NULL, `b` varbinary(1) NOT NULL However, when I run, ...
1
vote
1answer
194 views

Select Statement with Temp Column driven by Bitmask

I have a role system setup that checks to see if bits are set for specific roles. Each user has a specific assigned that is stored in our database and gives them access to different parts of the ...
1
vote
1answer
623 views

Boolean logic with BITs and Booleans in SQL Server

How can I mix boolean logic with bitwise and/or operators in SQL Server, specifically SQL Azure Database and/or SQL Server 2016? To demonstrate what I'm trying to do, consider the following script: ...
3
votes
1answer
860 views

Best Way to Index an INT Column Used for BitWise Queries

What is the best way to index a column for an efficient look-up based on a bitwise comparison in the WHERE clause e.g. SELECT ID, FLAGS, NAME FROM TABLE WHERE FLAGS & 4 = 4 I am in a SQL server ...
5
votes
1answer
11k views

How does the operator “&” work in sql server?

I was running a trace on one of our test servers when someone did this: and one of the queries I could catch in the trace was: declare @UserOption int select @UserOption=convert(int, c.value) from ...
1
vote
1answer
2k views

Oracle Equivalent of SQL Server's Bitwise Operators

I am trying to figure out all of the common bit-wise operations in Oracle. In SQL Server we have some very simple bit-wise operators to use against a bit-wise value: & - Evaluates if bit exists ...
0
votes
1answer
108 views

Postgres: extracting multiple bit-columns from single 'flags' column after join with 2nd table

I have a query similar to this below. As you can see, there are multiple parts which are very similar. SELECT id, aaaa, bbbb, tags ,( SELECT COUNT(*) > 0 ...
2
votes
2answers
3k views

Column To generate Flag Values for use in bitwise comparisons

We are in the process of creating a new application where various tables are used to hold enumerations. Since the IDs in these tables will be used in bitwise comparisons, we'd like to ensure new rows ...