OpCodes.Neg 字段


对一个值执行求反并将结果推送到计算堆栈上。Negates a value and pushes the result onto the evaluation stack.

public: static initonly System::Reflection::Emit::OpCode Neg;
public static readonly System.Reflection.Emit.OpCode Neg;
 staticval mutable Neg : System.Reflection.Emit.OpCode
Public Shared ReadOnly Neg As OpCode 



下表列出了指令的十六进制和 Microsoft 中间语言(MSIL)程序集格式以及简短的参考摘要:The following table lists the instruction's hexadecimal and Microsoft Intermediate Language (MSIL) assembly format, along with a brief reference summary:

格式Format 程序集格式Assembly Format 说明Description
6565 negneg 对当前位于堆栈顶部的值求反。Negates the value currently on top of the stack.

堆栈转换行为顺序如下:The stack transitional behavior, in sequential order, is:

  1. 将值推送到堆栈上。A value is pushed onto the stack.

  2. 从堆栈中弹出一个值并对其进行求反。A value is popped from the stack and negated.

  3. 将结果推送到堆栈上。The result is pushed onto the stack.

@No__t-0 指令对值求反并将结果推送到堆栈顶部。The neg instruction negates value and pushes the result on top of the stack. 返回类型与操作数类型相同。The return type is the same as the operand type.

整数值的求反是标准2的补码反运算。Negation of integral values is standard two's complement negation. 特别是,取消最多负数(不具有正号)将产生最大的负数。In particular, negating the most negative number (which does not have a positive counterpart) yields the most negative number. 若要检测此溢出,请改用 Sub_Ovf 指令(即从0减去)。To detect this overflow use the Sub_Ovf instruction instead (that is, subtract from 0).

取消浮点数不能溢出,取消 NaN 返回 NaN。Negating a floating-point number cannot overflow, and negating NaN returns NaN.

以下 @no__t 0 方法重载可以使用 @no__t 操作码:The following Emit method overload can use the neg opcode:

  • ILGenerator.Emit(OpCode)ILGenerator.Emit(OpCode)