Template:HasBitValueSet

From RadiWiki
Jump to: navigation, search

0It seems to be very difficult in MediaWiki to implement bit operations (or bitwise comparsion).

A possibility is to use a modulation operation of the double of the value, to determine if the value is present. 10 is bitvalue 8 and bitvalue 2. To check if bitvalue 2 is set double the bitvalue, and use it for the a modulo operation. Then with that result, do a modulo operation with the tested bitvalue. If it changes, then the bit was set.

  • 10 mod (2 * 2) => 2
  • 2 mod 2 => 0
  • 0 is different than the 2, so the bitvalue 2 was present in 10.