What's the name for this mathematical device used by programmers?

108 Views Asked by At

So a friend is trying to figure out what this is called so we can read more about it.

The concept is/was used by database designers, who needed a compact way to store a list of selected options as a single numerical value, where that number would be unique for any given selection of options.

This was done by assigning an ID value to each option that corresponded with an exponentiation of a base pair, and adding them all together. Since I'm not sure if anything I just said was correct, what I mean is (using base 2 as an example):

Option 1 ID: 1 (2^0)

Option 2 ID: 2 (2^1)

Option 3 ID: 4 (2^2)

So if your selection was both option 1 and 2, the value of that configuration would be 3 (1+2). If your selection was option 1 and 3, it would be 5 (1 + 4).

The presumed property here is that the resulting sum of any given configuration would be unique to that configuration, so that given the value of the sum, one would be able to work backwards to determine which option was selected.

This would be useful to, say, a database guy, who wants a compact way to store a list of selected options as a single value in a row of data.

Can anyone enlighten me on what I would google to learn more about this database storage technique / mathematical principle?

1

There are 1 best solutions below

0
On

This is normally called a "Bit field."