Alternative to bitwise operation

筅森魡賤 提交于 2019-12-04 17:16:31

An alternative could be to multiply prime numbers. To select, you would select columns where the modulus of the prime number into the value of the column is 0.

Example:

Value 1: 2
Value 2: 3
Value 3: 5
Value 4: 7

Value 2 & 3 would be 3*5 = 15
Values 1, 2, 3, 4 would be 2*3*5*7 = 210

To get the rows where value 1 is on, select where value % 2 == 0

You can always use this approach as long the number of bits is less equal than the bit length of the type for that column. If there are more bits to store you can use multiple columns(fields).

You can also use Bit Fields.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!