OpCodes.Div 字段


将两个值相除并将结果作为浮点(F 类型)或商(int32 类型)推送到计算堆栈上。Divides two values and pushes the result as a floating-point (type F) or quotient (type int32) onto the evaluation stack.

public: static initonly System::Reflection::Emit::OpCode Div;
public static readonly System.Reflection.Emit.OpCode Div;
 staticval mutable Div : System.Reflection.Emit.OpCode
Public Shared ReadOnly Div 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
5B5B divdiv 将两个值相除以返回商或浮点结果。Divides two values to return a quotient or floating-point result.

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

  1. value1 推送到堆栈上。value1 is pushed onto the stack.

  2. value2 推送到堆栈上。value2 is pushed onto the stack.

  3. value2 和 @no__t 从堆栈中弹出;value1 除以 @no__t。value2 and value1 are popped from the stack; value1 is divided by value2.

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

result @ no__t-1 @ no__t-2 div value2 满足以下条件:result = value1 div value2 satisfies the following conditions:

|result | = | value1 | / | value2 |,并且:| result | = | value1 | / | value2 |, and:

sign (result) = +,if 符号(value1) = sign (value2),或-,if 符号(value1) ~ = sign (value2sign(result) = +, if sign(value1) = sign(value2), or -, if sign(value1) ~= sign(value2)

@No__t 的指令将计算结果并将结果推送到堆栈上。The div instruction computes the result and pushes it on the stack.

整数除法向零截断。Integer division truncates towards zero.

有限数除以零会生成正确的无符号无限值。Division of a finite number by zero produces the correctly signed infinite value.

零除以零或无穷大按无穷产生 NaN (非数字)值。Dividing zero by zero or infinity by infinity produces the NaN (Not-A-Number) value. 除以无限大的任何数字都会产生零值。Any number divided by infinity will produce a zero value.

如果结果不能用结果类型表示,则整型运算将引发 ArithmeticExceptionIntegral operations throw ArithmeticException if the result cannot be represented in the result type. 如果 @no__t 为最大负值,则会发生这种情况,value2 为-1。This can happen if value1 is the maximum negative value, and value2 is -1.

如果 value2 为零,则整数运算引发 DivideByZeroExceptionIntegral operations throw DivideByZeroException if value2 is zero.

请注意,在基于 Intel 的平台上,计算时(minint div-1)会引发 OverflowExceptionNote that on Intel-based platforms an OverflowException is thrown when computing (minint div -1). 浮点运算永远不会引发异常(而是生成 Nan 或无穷大)。Floating-point operations never throw an exception (they produce NaNs or infinities instead).

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

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