anchor.diff:      Registers = array:fix(
                     array:resize(
                       M, array:from_list(
  -                         proplists:get_value(<<"registers">>, Struct), 0))),
  +                         decode_registers(proplists:get_value(<<"registers">>, Struct)),
  +                         0))),
   
       #hyper{p = P, registers = Registers}.
  +
  +encode_registers(Registers) ->
  +    ByteEncoded = array:foldl(fun (_I, V, A) ->
  +                                      [<<V:8/integer>> | A]
  +                              end, [], array:resize(Registers)),
  +
  +    base64:encode(
  +      iolist_to_binary(
  +        lists:reverse(ByteEncoded))).
  +
  +decode_registers(B) ->
  +    decode_registers(base64:decode(B), []).
  +
  +decode_registers(<<>>, Acc) ->
  +    lists:reverse(Acc);
  +decode_registers(<<I:8/integer, Rest/binary>>, Acc) ->
  +    decode_registers(Rest, [I | Acc]).
  +
  +%%
  +%% HELPERS
  +%%
   
   
   alpha(16) -> 0.673;
  
positive.code: alpha(64) -> 0.709;
  alpha(M)  -> 0.7213 / (1 + 1.079 / M).
  
  %%
  %% HELPERS
  %%
  
  
  pow(X, Y) ->
      math:pow(X, Y).
  
  
  
  run_of_zeroes(B) ->
      run_of_zeroes(1, B).
  
negative.code:     Hyper = insert_many(generate_unique(1024), new(14)),
      ?assertEqual(trunc(card(Hyper)), trunc(card(from_json(to_json(Hyper))))).
  
  encoding_test() ->
      Hyper = insert_many(generate_unique(100000), new(14)),
      ?assertEqual(trunc(card(Hyper)), trunc(card(from_json(to_json(Hyper))))).
  
  
  error_range_test() ->
      Run = fun (Cardinality, P) ->
                    lists:foldl(fun (V, H) ->
                                        insert(V, H)
                                end, new(P), generate_unique(Cardinality))
            end,
      Card = 100000,
      Delta = abs(Card - card(Run(Card, 16))),
      ?assert(Delta < Card * 0.01).
  
  
  
  
  
  