require 'bitvector' b = BitVector.new(100_000).randomize # 1e5 random bits a = BitVector.new(100_000).randomize # another 1e5 random bits c = a^b # exclusive or of 2*1e5 rand bits puts c.inspect File.open("testdata_mybits", "w") {|f| # Dump bit vector to file f.write Marshal.dump(c) } puts BitVector.from_bin(8, "10011011").ones.inspect puts c.to_i