Compiler Construction with ANTLR and Java
By Gary L. Schaps
Dr. Dobb's Journal March 1999
/** convert big endian integer to little endian format */ public static int toInt(int v) { int littleInt = (v & 0xFF) << 24; // LSB -> MSB littleInt |= (v & 0xFF00) << 8; // LSB + 1 -> LSB + 2 littleInt |= ((v & 0xFF0000) >>> 8); // LSB + 2 -> LSB + 1 littleInt |= ((v & 0xFF000000) >>> 24); // MSB -> LSB return(littleInt); }
Example 6: Method to transform a Java "portable" primitive type.
Copyright © 1999, Dr. Dobb's Journal