Template:DeviceTypeName

From RadiWiki
Revision as of 20:14, 28 June 2016 by Joro (talk | contribs)
Jump to navigation Jump to search


Converts the numeric value of a DeviceDriverType into a nice name

Only the basic values are detected, bit-combinations will not be splitted into several names! This is because it 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.