30.06.2012, 05:56
Here's what I mean.
This would allow you to save 155 bits into only 5 32-bit variables (20 bytes) versus 144 32-bit variables (576 bytes)
To save it, you would just save either bit[0] as an integer, or the whole thing as a string.
The reason I choose 31 bits over 32, is because when dealing with '0b10000000000000000000000000000000' or '0x80000000'. It returns "--" in a print log and sometimes something else.
try.
pawn Код:
new bits[5]; //31 values per increment
stock SetBit(bit,truefalse)
{
new cell=bit/31;
new adj=bit%31;
new value=floatround(floatpower(10,adj));
if(!truefalse)if(bits[cell]&value)bits[cell]-=value;
else if(!(bits[cell]&value))bits[cell]+=value;
}
stock GetBit(bit)
{
new cell=bit/31;
new value=floatround(floatpower(10,bit%31));
return (bits[cell]&value);
}
To save it, you would just save either bit[0] as an integer, or the whole thing as a string.
The reason I choose 31 bits over 32, is because when dealing with '0b10000000000000000000000000000000' or '0x80000000'. It returns "--" in a print log and sometimes something else.
try.
pawn Код:
printf("%d",0b10000000000000000000000000000000); //32 bits