file size question
Posted on 2006-06-30
I'm attempting to learn how to read file formats and am having some trouble figuring out what is going on here. The format description states:
"The value for file length is the total length of the file in 16-bit words (including the fifty
16-bit words that make up the header)."
This is how the file length is stored in the header:
Byte 24 File Length Integer Big Endian
I read the value from byte 24 as 4 bytes (integer size) in Big endian and I get the value 10106 which I thought would be valid, however I found someone else that wrote a library on the internet (w/ source code) that works and I'm trying to understand what they are doing as they get the value 20212 when I run it. Their code is:
psSHP->nFileSize = (pabyBuf * 256 * 256 * 256
+ pabyBuf * 256 * 256
+ pabyBuf * 256
+ pabyBuf) * 2;
I don't understand why they are multiplying by 256 to figure up the file size? And why is the right-most value multiplied by 2? thanks for any help!