Bit operators/shifting etc. faster than using normal defines etc? (also another question inside)
#1

now, im learning binary. thanks to Vince's and Kwarde's tutorial (oh and samp wiki) i wanted to know which one is faster.

e.g using

pawn Код:
enum (<<= 1)
{
    INVALID_TEAM,           //#define INVALID_TEAM 0
    TEAM_COPS = 1,          //#define TEAM_COPS 1
    TEAM_UNDERCOVERCIA,     //#define TEAM_UNDERCOVERCIA 2
    TEAM_ARMY,              //#define TEAM_ARMY 3
    TEAM_SWAT,              //#define TEAM_SWAT 4
    TEAM_CIVILIAN,          //#define TEAM_CIVILIAN 5
    TEAM_MEDIC,             //#define TEAM_MEDIC 6
    TEAM_FIREFIGHTER        //#define TEAM_FIREFIGHTER 7
}
so like gTeam[playerid] & TEAM_COPS

or
pawn Код:
enum
{
    INVALID_TEAM,           //#define INVALID_TEAM 0
    TEAM_COPS = 1,          //#define TEAM_COPS 1
    TEAM_UNDERCOVERCIA,     //#define TEAM_UNDERCOVERCIA 2
    TEAM_ARMY,              //#define TEAM_ARMY 3
    TEAM_SWAT,              //#define TEAM_SWAT 4
    TEAM_CIVILIAN,          //#define TEAM_CIVILIAN 5
    TEAM_MEDIC,             //#define TEAM_MEDIC 6
    TEAM_FIREFIGHTER        //#define TEAM_FIREFIGHTER 7
}
if(gTeam[playerid] == TEAM_COPS)

but yet it seems that binary is more dynamic? whereas you can add more than one teams to the player without creating a new variable

gTeam[playerid] |= TEAM_COPS
gTeam[playerid] |= MEDIC

will make them a medical cop?

so its like, instead of creating a new variable, e.g what cop skill they are. you can just do

if(gTeam[playerid] & TEAM_COPS | TEAM_MEDIC)

that detect if they are a medic and cop? so u can create your system more dynamically etc

?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)