Recently I've been toying with Java, assessing it largely by porting some of my C programs to it. However, I've now ran into a little problem, and no matter how many showers I take, I can't get Java off me(!).
I tried to port a program that deals with Wave files. Of course, all of the multi-byte numbers in it are little endian, but Java's big endian. Fearing that I may be stuck with a little endian for the rest of my life, I tried constructing this function inside my main class:-
This seems to work for all but certain numbers, I get strange results sometimes. As I haven't reinstalled my C compiler yet, I can't wallow in the safety of familiarity, so would anyone care to offer assistance?
public static int reverseInt(int source)
dest = ((source & 0xFF000000) >> 24) | ((source & 0xFF0000) >> 8) | ((source & 0xFF00) << 8) | ((source & 0xFF) << 24);