code: @Override
    public void writeDouble(double d) throws IOException {
      long n = Double.doubleToLongBits(d);
      if ((n >>> 63) > 0) {
        n ^= 0x7fffffffffffffffL;
      }
      writeLong(n);
    }
docs: A double is written as 8 bytes. It is encoded as a 64 bit long using the
  long encoding defined in this class. If it is a negative number, the
  complement of the 63 bits (every bit except the sign bit) is taken. This is
  to ensure proper ordering of negative numbers.
  
  @param d
  The double to encode.