original_string: private static function _encodeNegativeInteger(\GMP $num): string
      {
          $num = gmp_abs($num);
          // compute number of bytes required
          $width = 1;
          if ($num > 128) {
              $tmp = $num;
              do {
                  $width++;
                  $tmp >>= 8;
              } while ($tmp > 128);
          }
          // compute two's complement 2^n - x
          $num = gmp_pow("2", 8 * $width) - $num;
          $bin = gmp_export($num, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
          // if first bit is 0, prepend full inverted byte
          // to represent negative two's complement
          if (!(ord($bin[0]) & 0x80)) {
              $bin = chr(0xff) . $bin;
          }
          return $bin;
      }
code: private static function _encodeNegativeInteger(\GMP $num): string
      {
          $num = gmp_abs($num);
          // compute number of bytes required
          $width = 1;
          if ($num > 128) {
              $tmp = $num;
              do {
                  $width++;
                  $tmp >>= 8;
              } while ($tmp > 128);
          }
          // compute two's complement 2^n - x
          $num = gmp_pow("2", 8 * $width) - $num;
          $bin = gmp_export($num, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
          // if first bit is 0, prepend full inverted byte
          // to represent negative two's complement
          if (!(ord($bin[0]) & 0x80)) {
              $bin = chr(0xff) . $bin;
          }
          return $bin;
      }
code_tokens: private static function _encodeNegativeInteger ( \ GMP $ num ) : string { $ num = gmp_abs ( $ num ) ; // compute number of bytes required $ width = 1 ; if ( $ num > 128 ) { $ tmp = $ num ; do { $ width ++ ; $ tmp >>= 8 ; } while ( $ tmp > 128 ) ; } // compute two's complement 2^n - x $ num = gmp_pow ( "2" , 8 * $ width ) - $ num ; $ bin = gmp_export ( $ num , 1 , GMP_MSW_FIRST | GMP_BIG_ENDIAN ) ; // if first bit is 0, prepend full inverted byte // to represent negative two's complement if ( ! ( ord ( $ bin [ 0 ] ) & 0x80 ) ) { $ bin = chr ( 0xff ) . $ bin ; } return $ bin ; }
docstring: Encode negative integer to DER content.
  
  @param \GMP $num
  @return string
docstring_tokens: Encode negative integer to DER content .