I've been using a technique that consists in representing sets as binary numbers. This is, given a vocabulary $v = \{v_1, v_2, ..., v_n\}$ and a set $s = \{s_1, s_2, ..., s_m\}$ where $s_i \in v$, then the set $s$ can be represented as a binary number $b_s$ of length $n$ where
$$b_s[i] = \begin{cases} 1 \; \text{if} \; v[i] \in s \\ 0 \; \text{if} \; v[i] \notin s \\ \end{cases} $$
For example, if $v = \{a, b, c\}$ and $s = \{a, b\}$ then $b_s = 011$. And if $t=\{b, c\}$ then $b_t = 110$.
My question is how is this technique called. I've googled "represent a set as a binary number" and multiple variants, but nothing appears. Also, is this technique something standard?
It's a set implemented using a bit array.
And it is a “standard” technique. The first time I encountered it was in Turbo Pascal, which used it to implement its
settypes.An advantage of this representation is that set operations can easily and efficiently be implemented using bitwise operators:
x & yfor intersection,x | yfor union,x ^ yfor symmetric difference, orx & ~yfor difference.The main disadvantage is that it can't be used for sets of types with large numbers of possible values. (If
intis 32 bits, then eachset<int>would be $2^{32}$ bits = 512 megabytes.) For this reason, Turbo Pascal only allowed sets to contain values between 0 and 255, thus limiting the maximum size of asetobject to a more practical 256 bits = 32 bytes.