Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 10 of 15 total |
Test a bit in an integer field in a filter?? |
Thu, Jul 22 2021 5:55 PM | Permanent Link |
Ian Branch | Hi Team,
I have an integer field where each bit means something. How can I test a bit in the integer value/field in a filter? Regards & TIA, Ian |
Thu, Jul 22 2021 11:09 PM | Permanent Link |
Raul Team Elevate | On 7/22/2021 5:55 PM, Ian Branch wrote:
> Hi Team, > I have an integer field where each bit means something. > How can I test a bit in the integer value/field in a filter? Have not tested in filter but divide by the value corresponding to bit position (power of 2 basically) and then use MOD 2 to see if last bit is 1. use floor to ensure int values. Basically Value mod 2 = 1 if last bit is set (floor(value/2)) mod 2=1 for 2nd last (floor(value/4)) mod 2=1 for 3nd last etc Raul |
Fri, Jul 23 2021 12:57 AM | Permanent Link |
Ian Branch | Thanks Raul. Messy when testing several bits but it works.
I have asked Tim to consider a BitTest() function in Filtering.. i.e. BitTest(fieldName, bit) return true or false of set or not. Regards & Tks again, Ian |
Fri, Jul 23 2021 2:27 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Raul
Wow - colour me impressed Roy Lambert |
Fri, Jul 23 2021 2:27 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Ian
To build on Raul's post - why not set up computed (or generated) columns to represent each bit. Should make accessing easier Roy Lambert |
Fri, Jul 23 2021 2:40 AM | Permanent Link |
Ian Branch | Show off.
|
Fri, Jul 23 2021 3:19 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Ian
Yeah - but I'm pretty with it Roy Lambert (posting as a compulsive liar) |
Fri, Jul 23 2021 2:47 PM | Permanent Link |
Terry Swiers | > To build on Raul's post - why not set up computed (or generated) columns to represent each bit. Should make accessing easier
Or create your own function in the schema... CREATE FUNCTION "IsBitSet" (IN "Value" INTEGER, IN "BitPos" SMALLINT) RETURNS BOOLEAN BEGIN DECLARE lValue INTEGER; DECLARE Result Boolean default False; IF (BitPos >= 0) and (BitPos <= 31) THEN SET lValue = FLOOR(Value/POWER(2, BitPos)); SET Result = lValue mod 2 = 1; END IF; Return Result; END VERSION 1.00 |
Fri, Jul 23 2021 4:40 PM | Permanent Link |
Ian Branch | Hi Terry,
Interesting thought. How would I use that in an EDBTable filter? Regards, Ian (P.S. I have filed that little bit of code away for future reference.) |
Fri, Jul 23 2021 6:16 PM | Permanent Link |
Terry Swiers | > How would I use that in an EDBTable filter? Just like any other filter condition. If you are filtering on the column "ABC"... Table.Filter := 'IsBitSet(ABC, 0)' Table.Filtered := True; |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Tuesday, April 30, 2024 at 03:55 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |