Inconsistent String Behavior

For general discussion related FlowStone
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Inconsistent String Behavior

Post by Tronic »

this is the class I use for Bitmask, it take only 199 byte space to store 1024 bit in the string preset

Code: Select all

class Bitmask
 
   def initialize
      @mask = 0
   end
   
   def set idx
      @mask |= 1 << idx
   end
   
   def unset idx
      @mask &= ~(1 << idx)
   end
   
   def get idx
      @mask & (1 << idx) > 0
   end

   def clear
      @mask = 0
   end
   
   def save
      @mask.to_s(36)
   end
   
   def load data
      @mask = data.to_i(36)
   end
end

Edit: some correction
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Inconsistent String Behavior

Post by tulamide »

I don't see where this is any different, apart from my additional safety (I'm avoiding null bytes and don't use bignums, but fixnums, because they are accessed with fewer cycles). Also, I'm already down to 148 bytes (for 1035 states) ;)
"There lies the dog buried" (German saying translated literally)
Post Reply