Answer the question
In order to leave comments, you need to log in
How to understand what icons the server has?
I read here that you need to use a bitwise operator to understand if this or that icon and should be displayed true or false , but I don’t get the
Code:
const status = 40;
status & 8
// 8
status & 10
// 8
status & 20
// 0
Answer the question
In order to leave comments, you need to log in
The documentation is crooked.
It is necessary to check by the hexadecimal masks indicated below.
With a bitwise AND (&), you get zero if the bit is not set, or the value of the bit if it is. Zero, traditionally, is implicitly cast to false, any non-zero value to true.
const status = 40; // 0x28
status & 0x08
// 8 (0x08, true)
status & 0x10
// 0 (false)
status & 0x20
// 32 (0x20, true)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question