Storing 144 true/false values in mySQL
#7

Here's what I mean.
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);
}
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 Код:
printf("%d",0b10000000000000000000000000000000); //32 bits
Reply


Messages In This Thread
Storing 144 true/false values in mySQL - by MP2 - 30.06.2012, 03:13
Re: Storing 144 true/false values in mySQL - by ReneG - 30.06.2012, 03:36
Re: Storing 144 true/false values in mySQL - by Joe Staff - 30.06.2012, 03:44
Re: Storing 144 true/false values in mySQL - by MP2 - 30.06.2012, 04:04
Re: Storing 144 true/false values in mySQL - by Steven82 - 30.06.2012, 04:06
Re: Storing 144 true/false values in mySQL - by MP2 - 30.06.2012, 04:09
Re: Storing 144 true/false values in mySQL - by Joe Staff - 30.06.2012, 05:56

Forum Jump:


Users browsing this thread: 1 Guest(s)