Compact integer in Scripts I've been looking at the compact representation of integers for integer operations in the Script language. It seems that most operations produce or push byte arrays, but when integer operations are performed those arrays are interpreted using a signed compact format.  Is this format actually defined anywhere, or is it strictly bitcoin specific? 

As I understand it you can process up to 4 bytes as a integer, the negative of an integer is binary or'd with 0x80. I'm having trouble decoding 1-4 byte negative integers into the correct bit string encoding.

Does anyone have any examples, or can point me in the right direction?
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