Hi All,
I am sure that there is an obvious answer to this that I have missed. I need to check if a specific bit within an Offset is set.
Specifically, Offset 3122. (Radio audio switches) I need to check if the bit in location 2^5 (COM receive both) is set.
I am new to working with bits so I apologize if the solution is obvious. I have read Pete's explanations on understanding bits, which were all very helpful. I have found the ipc library functions to work with Offset values to clear specific bits, set specific bits, toggle, etc, but I cannot find a similar function to evaluate the value at a current bit location using a mask. I've read threads to understand how to set specific bits using decimal values. I can't figure out, however, if there is a way to use math to determine if a specific bit is set.
I've also reviewed the logic functions within the LUA library and cant figure out how I could use these to achieve my goal. I fear that there is some obvious way to perform this task that I'm missing.
The only solution that my small brain could come up with is:
1) Read the 3122 Offset value.
2) Write the value into an Offset that is open to my temporary use.
3) Use the ipc.clearbitsUB function on this temporary Offset to clear all bits except for 2^5 using an appropriate mask.
4) Read the updated value from this temporary Offset location.
5) The decimal value should either be 32 or 0. A value of 32 tells me that the bit at 2^5 is set, 0 tells me that it was not set.
Can someone enlighten me on the simple solution for checking if a specific bit is set? Thank you in advance!
Prepar3D, FSUIPC 4.957