user17055: 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?

user15358: 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

user20835: CompactSize Unsigned Integers are not used in Script, they are used on the Bitcoin protocol to signify the amount of bytes that the next data structure contains. 
You are confusing these with ScriptNumbers, which are interpreted for Arithmetic operations inside of the Script Interpreter.
It should be noted that these actually can be 5 bytes, however if you perform another operation on that 5 byte integer, you will receive an error in the Interpreter. 
If you want to see how negative numbers are handled you can look at the implementation of CScriptNum, which the underlying numeric type is a int64_t

17055: <p>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? </p>

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

<p>Does anyone have any examples, or can point me in the right direction?</p>
 15358: <p>generic big endian MPI format
bitcoin-specific little endian format, with implicit size</p>

<p>python implementation</p>

<p><a href="https://github.com/petertodd/python-bitcoinlib/blob/master/bitcoin/core/_bignum.py" rel="nofollow">https://github.com/petertodd/python-bitcoinlib/blob/master/bitcoin/core/_bignum.py</a></p>
 20835: <p>CompactSize <strong>Unsigned</strong> Integers are not used in Script, they are used on the Bitcoin protocol to signify the amount of bytes that the next data structure contains. </p>

<p>You are confusing these with ScriptNumbers, <a href="https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp#L765-L767" rel="nofollow">which are interpreted for Arithmetic operations inside of the Script Interpreter</a>.</p>

<p>It should be noted that these actually <strong>can</strong> be 5 bytes, however if you perform <strong>another</strong> operation on that 5 byte integer, you will receive an error in the Interpreter. </p>

<p>If you want to see how negative numbers are handled you can look at the <a href="https://github.com/bitcoin/bitcoin/blob/ff46dd4a3457c321aef14f9778094c9db9b00083/src/script/script.h#L210" rel="nofollow">implementation of CScriptNum, which the underlying numeric type is a int64_t</a></p>
