Bitcoin script number encoding/decoding.
Numbers are encoded as little-endian byte arrays with the sign bit in the MSB of the last byte.
Summary
Functions
Decode a binary script number to an integer.
Encode an integer as a binary script number.
Check if a binary is minimally encoded as a script number.
Functions
Decode a binary script number to an integer.
Examples
iex> BSV.Script.ScriptNum.decode_num(<<>>)
0
iex> BSV.Script.ScriptNum.decode_num(<<0x81>>)
-1
Encode an integer as a binary script number.
Examples
iex> BSV.Script.ScriptNum.encode_num(0)
<<>>
iex> BSV.Script.ScriptNum.encode_num(-1)
<<0x81>>
Check if a binary is minimally encoded as a script number.