anchor.diff:    <<1:1, Value:7/integer, 1:1, (Value bsr 7):7/integer, 1:1, (Value bsr 14):7/integer, 1:1, (Value bsr 21):7/integer, 0:1, (Value bsr 28):7/integer>>.
   
   
  +-spec decode(binary()) -> {integer(), binary()}.
  +decode(Bin) when is_bitstring(Bin) ->
  +  decode(Bin, unsigned).
   
   -spec decode_signed(bitstring()) -> integer().
  -decode_signed(<<0:1, Value/bitstring>>) ->
  -  decode(Value);
  +decode_signed(Bin) ->
  +  decode(Bin, signed).
   
  -decode_signed(<<1:1, Value/bitstring>>) ->
  -  {Result, Tail} = decode(Value),
  -  {-Result, Tail}.
  +decode(Bin, signed) ->
  +  {Size, UValue, Tail} = take_chunks(Bin, 0, 0),
  +  <<Value:Size/signed-integer>> = <<UValue:Size/unsigned-integer>>,
  +  {Value, Tail};
   
  +decode(Bin, unsigned) ->
  +  {_Size, Value, Tail} = take_chunks(Bin, 0, 0),
  +  {Value, Tail}.
   
  +take_chunks(<<0:1, Chunk:7/integer, Tail/bitstring>>, Acc, Shift) ->
  +  Result = (Chunk bsl Shift) bor Acc,
  +  {Shift+7, Result, Tail};
   
  --spec decode(binary()) -> {integer(), binary()}.
  -decode(Bin) when is_bitstring(Bin) ->
  -  decode_chunks(Bin, []).
  -
  -decode_chunks(<<0:1, Chunk:7/integer, Tail/bitstring>>, Acc) ->
  -  Result = lists:foldl(fun(V, Sum) ->
  -    (Sum bsl 7) bor V
  -  end, 0, [Chunk|Acc]),
  -  {Result, Tail};
  -  
  -decode_chunks(<<1:1, Chunk:7/integer, Tail/bitstring>>, Acc) ->
  -  decode_chunks(Tail, [Chunk|Acc]).
  -
  -
  -decode1(<<0:1, V0:7, Tail/bitstring>>) ->
  -  {V0, Tail};
  -
  -decode1(<<1:1, V0:7, 0:1, V1:7, Tail/bitstring>>) ->
  -  {(V1 bsl 7) bor V0, Tail};
  -
  -decode1(<<1:1, V0:7, 1:1, V1:7, 0:1, V2:7, Tail/bitstring>>) ->
  -  {(V2 bsl 14) bor (V1 bsl 7) bor V0, Tail};
  -
  -decode1(<<1:1, V0:7, 1:1, V1:7, 1:1, V2:7, 0:1, V3:7, Tail/bitstring>>) ->
  -  {(V3 bsl 21) bor (V2 bsl 14) bor (V1 bsl 7) bor V0, Tail};
  -
  -decode1(<<1:1, V0:7, 1:1, V1:7, 1:1, V2:7, 1:1, V3:7, 0:1, V4:7, Tail/bitstring>>) ->
  -  {(V4 bsl 21) bor (V3 bsl 21) bor (V2 bsl 14) bor (V1 bsl 7) bor V0, Tail}.
  +take_chunks(<<1:1, Chunk:7/integer, Tail/bitstring>>, Acc, Shift) ->
  +  NextAcc = (Chunk bsl Shift) bor Acc,
  +  take_chunks(Tail, NextAcc, Shift+7).
   
   
   % EUnit tests
  
positive.code: 
  
  -spec encode_signed(integer()) -> bitstring().
  encode_signed(Value) when is_integer(Value) andalso Value >= 0 ->
    <<0:1, (encode(Value))/bitstring>>;
  
  encode_signed(Value) when is_integer(Value) andalso Value < 0 ->
    <<1:1, (encode(-Value))/bitstring>>.
  
  
  -spec encode(non_neg_integer()) -> binary().
  encode(Value) when is_integer(Value) andalso Value >= 0 ->
    encode_unsigned(Value).
  
  encode_unsigned(Value) ->
    case Value bsr 7 of
      0 ->
        <<0:1, Value:7/integer>>;
      NextValue ->
        <<1:1, Value:7/integer, (encode_unsigned(NextValue))/binary>>
    end.
  
  
  encode1(Value) when is_integer(Value) andalso Value >= 0 andalso Value < 128 ->
  
negative.code: decode_test() ->
    ?assertEqual({624485,<<57,113,1:4>>}, decode(<<16#E5, 16#8E, 16#26, 57,113,1:4>>)).
  
  encode_signed_test() ->
    ?assertEqual(<<16#9B, 16#F1, 16#59>>, encode_signed(-624485)).
  
  decode_signed_test() ->
    ?assertEqual({-624485,<<57,113,1:4>>}, decode_signed(<<16#9B, 16#F1, 16#59, 57,113,1:4>>)).
  
  
  measure(F) ->
  