Brian Dunning's FileMaker Custom Functions

BitTest2 ( value ; bit )

Checks whether bit 'bit' in value 'value' is on or off

  Average rating: 4.2 (34 votes) Log in to vote

Stephen Drake   Stephen Drake
Synergy
n/a

Share on Facebook Share on Twitter

  Sample input:
33 ; 5
  Sample output:
1

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

A non-recursive alternative to BitTest.

Bits are numbered from zero.

Div ( value ; 2 ^ bit ) is odd if the tested bit is set,
lower bits that are set add zero to the result,
higher bits that are set add an even number to the result.

If required, you could add error checking to make sure bit and value are >= 0.
Alternatively, you can use the function as is to test bits in the fractional part of the value or to test negative values.

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 15 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth:

Under construction. Email me your wish list for improvements.