double readDoubleLittleEndian( ) { // get the 8 unsigned raw bytes, accumulate to a long and then // convert the 64-bit pattern to a double. long accum = 0; for ( int shiftBy=0; shiftBy<64; shiftBy+=8 ) { // must cast to long or the shift would be done modulo 32 accum |= ( (long)( readByte() & 0xff ) ) << shiftBy; } return Double.longBitsToDouble( accum ); // there is no such method as Double.reverseBytes( d ); }