public static long incTwoBytePrimaryByOffset ( long basePrimary , boolean isCompressible , int offset ) { // Extract the second byte, minus the minimum byte value, // plus the offset, modulo the number of usable byte values, plus the minimum. // Reserve the PRIMARY_COMPRESSION_LOW_BYTE and high byte if necessary. long primary ; if ( isCompressible ) { offset += ( ( int ) ( basePrimary >> 16 ) & 0xff ) - 4 ; primary = ( ( offset % 251 ) + 4 ) << 16 ; offset /= 251 ; } else { offset += ( ( int ) ( basePrimary >> 16 ) & 0xff ) - 2 ; primary = ( ( offset % 254 ) + 2 ) << 16 ; offset /= 254 ; } // First byte, assume no further overflow. return primary | ( ( basePrimary & 0xff000000 L ) + ( ( long ) offset << 24 ) ) ; }
Increments a 2 - byte primary by a code point offset .