I've a sum build of 0 up to 3 specific decimal numbers that can build 8 different sums:
100 --- 100 --- 100 --- 100 ---
200 200 --- --- 200 200 --- ---
+ 400 + 400 + 400 + 400 + --- + --- + --- + ---
----- ----- ----- ----- ----- ----- ----- -----
700 600 500 600 300 200 100 0
The decimal numbers are scaled by doubling the next smaller number starting at a specific offset. They might be for example in the following sets instead:
{ 300, 600, 1200, ..}
{ 7, 14, 28, ..}
It is possible to figure out if a specific number is added by simply dividing by the offset and then running a bitmask check:
(sum / offset) & 1 == true if the first decimal number is added.
(sum / offset) & 2 == true if the second decimal number is added.
(sum / offset) & 4 == true if the third decimal number is added.
Is there any faster algorithm than that?
BTW: Since this is not exactly bitmasking how is it called instead? Decimal masking? Decimal sum multiplexing? Bitmasking with offset? Sum masking? WTF bit masking?