code: public static void writeLongSequence(long hd, long hr, ByteBuffer buf) {
          if(hr < hd)
              throw new IllegalArgumentException("hr (" + hr + ") has to be >= hd (" + hd + ")");
  
          if(hd == 0 && hr == 0) {
              buf.put((byte)0);
              return;
          }
  
          long delta=hr - hd;
  
          // encode highest_delivered followed by delta
          byte bytes_for_hd=bytesRequiredFor(hd), bytes_for_delta=bytesRequiredFor(delta);
          byte bytes_needed=encodeLength(bytes_for_hd, bytes_for_delta);
          buf.put(bytes_needed);
  
          for(int i=0; i < bytes_for_hd; i++)
              buf.put(getByteAt(hd, i));
  
          for(int i=0; i < bytes_for_delta; i++)
              buf.put(getByteAt(delta, i));
      }
docs: Writes 2 sequence numbers (seqnos) in compressed format to buf.
  The seqnos are non-negative and hr is guaranteed to be &gt;= hd.
  <p/>
  Once variable-length encoding has been implemented, this method will probably get dropped as we can simply
  write the 2 longs individually.
  @param hd the highest delivered seqno. Guaranteed to be a positive number
  @param hr the highest received seqno. Guaranteed to be a positive number. Greater than or equal to hd
  @param buf the buffer to write to