Do you pad out the front with zeros?
If you have 0xFC9782 does it become 0xFE00FC9782? I've seen some randomly complicated padding before so I'm just checking.
Eg. Software I was using stored hex in index orders [3][1][4][2][0][5] for some reason...
No you dont. If you can read Python code here is an implementation which I find easy to understand :
https://github.com/Crypto-lyon/genesis-parser/blob/c01167295e01570baf687c323ea6b7b311e5ba23/parser.py#L3. However the comments are in french because I made it for a french workshop, so feel free to ask question if something seems magic.
EDIT : The algorithm
Read the first byte from the file descriptor
If the first byte is less than 0xfd :
The number is the first byte
Else if the first byte is equal to 0xfd:
Read the second byte
The number is the second byte
Else if the first byte is equal to 0xfe:
Read the second and third bytes
The number is the second and third bytes
Else if the first byte is equal to 0xff:
Read the second third and fourth bytes, this is the number