Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread & operator
Fri, Dec 5 2014 11:42 AMPermanent Link

Mirco Malagoli

Hi,
I am storing binary value as an Integer in a table. I need to check if a particular bit is set.
How can I do without & operator?

Thanks
Fri, Dec 5 2014 1:38 PMPermanent Link

Raul

Team Elevate Team Elevate

On 12/5/2014 11:42 AM, Mirco Malagoli wrote:
> I am storing binary value as an Integer in a table. I need to check if a particular bit is set.
> How can I do without & operator?


Bitwise operations are not currently present in DBISAM SQL. They are
still on the roadmap (have been for awhile now).

Options i can suggest:
- do a custom engine function for Bitwise AND
- use delphi code
- convert data into separate boolean fields if you need to use SQL

Raul
Mon, Dec 8 2014 8:24 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Mirco,

In addition to what Raul said, if you want to use SQL you can also use this expression:
  
  CAST(X/POWER(2,N) AS INTEGER) MOD 2

where X is your integer column and N is the order of the bit that you want to test.
The expression evaluates to the value of the Nth bit.
Please be aware that it only works for X >= 0, so you can't use the 31th bit.

--
Fernando Dias
[Team Elevate]
Image