You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently trying to add int64 encoders and decoders to elm-protocol-buffers
and I'm struggling to implement the VarInt encoding.
The int32 version currently converts the number to base 128, right shifts and continues in a loop.
This is the code:
toVarIntEncoders : Int -> List Encode.Encoder
toVarIntEncoders value =
let
base128 =
Bitwise.and 0x7F value
higherBits =
Bitwise.shiftRightZfBy 7 value
in
if higherBits /= 0x00 then
Encode.unsignedInt8 (Bitwise.or 0x80 base128) :: toVarIntEncoders higherBits
else
[ Encode.unsignedInt8 base128 ]
I cannot do this with Int64, since the inner values are not exposed.
Using Int64.encode instead of Encode.unsignedInt8 has the correct first two bytes but too many zeros afterwards.
The text was updated successfully, but these errors were encountered:
I'm currently trying to add int64 encoders and decoders to elm-protocol-buffers
and I'm struggling to implement the VarInt encoding.
The int32 version currently converts the number to base 128, right shifts and continues in a loop.
This is the code:
I cannot do this with Int64, since the inner values are not exposed.
Using Int64.encode instead of Encode.unsignedInt8 has the correct first two bytes but too many zeros afterwards.
The text was updated successfully, but these errors were encountered: