Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define BitVar:%0<%1> %0[(((%1) + cellbits) / cellbits)]
- main()
- {
- new BitVar:gPlayerData<16>;
- setArrayBit(gPlayerData, 4, true);
- setArrayBit(gPlayerData, 2, false);
- new semBit[16];
- semBit[4] = _:true;
- semBit[2] = _:false;
- return printf("\n-----------------------------------------------------------------------------\n\n\t [TESTANDO BITS] \n (alocação padrão %d) (alocação manipulada: %d) \n\n-----------------------------------------------------------------------------\n\n\n\n", sizeof(semBit), sizeof(gPlayerData));
- }
- getArrayBit(arrayBits[], arrayIndex)
- {
- return bool: ((arrayBits [arrayIndex / cellbits] & (1 << (arrayIndex % cellbits))) != _:false);
- }
- setArrayBit(arrayBits[], arrayIndex, bool:arrayValue)
- {
- return arrayBits[arrayIndex / cellbits] = !arrayValue ? arrayBits[arrayIndex / cellbits] & ~(1 << (arrayIndex % cellbits)) : arrayBits[arrayIndex / cellbits] | (1 << (arrayIndex % cellbits));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement