class RawBits {

    static int compare( long lhsRawBits, byte lhsType, long rhsRawBits, byte rhsType )
    {
        // case integral - integral
        if ( lhsType == BYTE ||
                lhsType == SHORT ||
                lhsType == INT ||
                lhsType == LONG )
        {
            return compareLongAgainstRawType( lhsRawBits, rhsRawBits, rhsType );
        }
        else if ( lhsType == FLOAT )
        {
            double lhsFloat = Float.intBitsToFloat( (int) lhsRawBits );
            return compareDoubleAgainstRawType( lhsFloat, rhsRawBits, rhsType );
        }
        else if ( lhsType == DOUBLE )
        {
            double lhsDouble = Double.longBitsToDouble( lhsRawBits );
            return compareDoubleAgainstRawType( lhsDouble, rhsRawBits, rhsType );
        }
        // We can not throw here because we will visit this method inside a pageCursor.shouldRetry() block.
        // Just return a comparison that at least will be commutative.
        return Long.compare( lhsRawBits, rhsRawBits );
    }

}