disable broken tests on net_4_0
[mcs.git] / docs / ecma334 / 14.7.2.xml
blob8055d33f62a91ebff54e2dd78d1522ed08bb3807
1 <?xml version="1.0"?>
2 <clause number="14.7.2" title="Division operator">
3   <paragraph>For an operation of the form x / y, binary operator overload resolution (<hyperlink>14.2.4</hyperlink>) is applied to select a specific operator implementation. The operands are converted to the parameter types of the selected operator, and the type of the result is the return type of the operator. </paragraph>
4   <paragraph>The predefined division operators are listed below. The operators all compute the quotient of x and y. <list><list_item> Integer division: <code_example><![CDATA[
5 int operator /(int x, int y);  
6 uint operator /(uint x, uint y);  
7 long operator /(long x, long y);  
8 ulong operator /(ulong x, ulong y);  
9 ]]></code_example>If the value of the right operand is zero, a System.DivideByZeroException is thrown. The division rounds the result towards zero, and the absolute value of the result is the largest possible integer that is less than the absolute value of the quotient of the two operands. The result is zero or positive when the two operands have the same sign and zero or negative when the two operands have opposite signs. If the left operand is the maximum negative <keyword>int</keyword> or <keyword>long</keyword> value and the right operand is -1, an overflow occurs. In a checked context, this causes a System.OverflowException to be thrown. In an unchecked context, the overflow is not reported and the result is instead the value of the left operand. </list_item><list_item> Floating-point division: <code_example><![CDATA[
10 float operator /(float x, float y);  
11 double operator /(double x, double y);  
12 ]]></code_example>The quotient is computed according to the rules of IEEE 754 arithmetic. The following table lists the results of all possible combinations of nonzero finite values, zeros, infinities, and NaN's. In the table, x and y are positive finite values. z is the result of x / y. If the result is too large for the destination type, z is infinity. If the result is too small for the destination type, z is zero. <table_line>+y <unicode>150</unicode>y +0 <unicode>150</unicode>0 +<infinity/> <unicode>150</unicode><infinity/> NaN </table_line>
13 <table_line>+x +z <unicode>150</unicode>z +<infinity/> <unicode>150</unicode><infinity/> +0 <unicode>150</unicode>0 NaN </table_line>
14 <table_line><unicode>150</unicode>x <unicode>150</unicode>z +z <unicode>150</unicode><infinity/> +<infinity/><unicode>150</unicode>0 +0 NaN </table_line>
15 <table_line>+0 +0 <unicode>150</unicode>0 NaN NaN +0 <unicode>150</unicode>0 NaN </table_line>
16 <table_line><unicode>150</unicode>0 <unicode>150</unicode>0 +0 NaN NaN <unicode>150</unicode>0 +0 NaN </table_line>
17 <table_line>+<infinity/> +<infinity/> <unicode>150</unicode><infinity/> +<infinity/> <unicode>150</unicode><infinity/> NaN NaN NaN </table_line>
18 <table_line><unicode>150</unicode><infinity/><unicode>150</unicode><infinity/> +<infinity/><unicode>150</unicode><infinity/> +<infinity/> NaN NaN NaN </table_line>
19 <table_line>NaN NaN NaN NaN NaN NaN NaN NaN </table_line>
20 </list_item><list_item> Decimal division: <code_example><![CDATA[
21 decimal operator /(decimal x, decimal y);  
22 ]]></code_example>If the value of the right operand is zero, a System.DivideByZeroException is thrown. If the resulting value is too large to represent in the <keyword>decimal</keyword> format, a System.OverflowException is thrown. If the result value is too small to represent in the <keyword>decimal</keyword> format, the result is zero. The scale of the result, before any rounding, is the smallest scale that will preserve a result equal to the exact result. Decimal division is equivalent to using the division operator of type System.Decimal. </list_item></list></paragraph>
23 </clause>