Convert a 3-byte array into a single size integer?
I have a file I am trying to decode and the size of the portion of the file I need is specified by 3 bytes in its header. How can I convert these 3 separate bytes into 1 single integer?
Re: Convert a 3-byte array into a single size integer?
Originally Posted by MrViggy
What, exactly, does each of the bytes represent? Are they part of a single 24 bit integer?
Viggy
Yes they are part of a single 24 bit integer, but I can't figure out how to get the program to recognize them as a single integer, and not 3 different bytes in an array...
Re: Convert a 3-byte array into a single size integer?
I don't know how to create a 24-bit integer, but if it were a 32-bit integer conversion would look something like this, where buffer contains the binary representation of a 4-byte integer. I assume a 24-bit integer would be similar. I know short = 16 bit integer, long = 32 bit. I don't know what is a 24 bit. Yes, I know those sizes are not guarenteed, but that's what they are on 16 and 32 bit operating systems such as MS-DOS, MS-Windows and *nix.
Re: Convert a 3-byte array into a single size integer?
Originally Posted by DaBoonDockSaint
anyone know how to do this in .net?
Yes, in the exact same way. What does using .Net have to do with anything if it is a c++ program? You still have the same problem and the same kind of solution.
Bookmarks