Bitwise operators in MSD axapta


Bitwise operators in axapta


Bitwise operators are, as the name indicates, used to evaluate expression by using arithmetic and conditional operators at the bit level. These bitwise operators can only be used with integer values.
A common situation for using bitwise operators is as an alternative to having a set of variables setting true or false values if you have to control some access controls with several levels. However the use of bitwise operators will make your code more difficult to read. This might be the reason that these operators are not commonly used in the standard application. In fact, the only place you may find yourself using the bitwise
operators is when you are interfacing with external applications such as interacting directly with Windows API or need to do any low-level operations on the database.
To be able to understand the result of an expression using bitwise operators, you will have to translate the integer values to binary numbers.
13 & 10 // 1101 bitwise and 1010
The expression 13 & 10 will give the result 8. This is because 13 and 10 is compared bit by bit and only the bits set for both digits are counted. The expression is translated to binary after the comment. Only the fourth bit is equal, and thereby the result is 8.