For example, if the number is represented in hexadecimal as "0x60", in binary it would be "01100000". How can we determine the value of, let's say, the 2nd or 7th bit? Are there any built-in functions for this in MikroTik?
I tried to do the following:
Code: Select all
:local value 0x60;
:local bit0Value ( $value & 0x1 > 0 );
:put "The value of the 0 bit.: $bit0Value";
:local bit1Value ( $value & 0x2 > 0 );
:put "The value of the 1 bit.: $bit1Value";
:local bit2Value ( $value & 0x3 > 0 );
:put "The value of the 2 bit.: $bit2Value";
:local bit3Value ( $value & 0x4 > 0 );
:put "The value of the 3 bit.: $bit3Value";
:local bit4Value ( $value & 0x5 > 0 );
:put "The value of the 4 bit.: $bit4Value";
:local bit5Value ( $value & 0x6 > 0 );
:put "The value of the 5 bit.: $bit5Value";
:local bit6Value ( $value & 0x7 > 0 );
:put "The value of the 6 bit.: $bit6Value";
:local bit7Value ( $value & 0x8 > 0 );
:put "The value of the 7 bit.: $bit7Value";