March 01, 1999
Compiler Construction with ANTLR and Java
Compiler Construction with ANTLR and JavaBy Gary L. SchapsDr. 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
|
|
||||||||||||||||||||||||||||
|
|
|
|