10.08.2012, 14:00
Quote:
The generator is very nice!
Anyway can you give some info how it works? (How generate and how you read this information) I tried to do it myself without generator, but I don't know read the values without cycle. |
Than it creates a list of bits from the lowest till the highest value (cells = ((max - min) / 32))
At last it sets the bits at the correct positions (value1 - min; value2 - min; ...)
pawn Код:
stock func(value) {
static const valid_values[] = {
// values
};
if (min <= value <= max) {
value -= min;
// it gets the correct cell with "valid_values[value >>> 5]" or "valid_values[value / 32]"
// with "value & 31" it extracts the position, similar to "value % 32"
// 1 << position, is just 2 ^ position (Exponentiation)
// the & just checks now if the bit is set in the cell
return (valid_values[value >>> 5] & (1 << (value & 31))) || false;
}
return false;
}