Compact integer in Scripts
generic big endian MPI format
bitcoin-specific little endian format, with implicit size

python implementation

https://github.com/petertodd/python-bitcoinlib/blob/master/bitcoin/core/_bignum.py