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?