13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>C#</strong> LANGUAGE SPECIFICATIONand 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.+y –y +0 –0 +∞ –∞ NaN+x +z –z +∞ –∞ +0 –0 NaN–x –z +z –∞ +∞ –0 +0 NaN+0 +0 –0 NaN NaN +0 –0 NaN–0 –0 +0 NaN NaN –0 +0 NaN+∞ +∞ –∞ +∞ –∞ NaN NaN NaN–∞ –∞ +∞ –∞ +∞ NaN NaN NaNNaN NaN NaN NaN NaN NaN NaN NaN• Decimal division:decimal operator /(decimal x, decimal y);If the value of the right operand is zero, a System.DivideByZeroException is thrown. If theresulting value is too large to represent in the decimal format, a System.OverflowException isthrown. If the result value is too small to represent in the decimal format, the result is zero. The scaleof the result, before any rounding, is the smallest scale that will preserve a result equal to the exactresult.Decimal division is equivalent to using the division operator of type System.Decimal.14.7.3 Remainder operatorFor an operation of the form x % y, binary operator overload resolution (§14.2.4) is applied to select aspecific operator implementation. The operands are converted to the parameter types of the selectedoperator, and the type of the result is the return type of the operator.The predefined remainder operators are listed below. The operators all compute the remainder of thedivision between x and y.• Integer remainder:int operator %(int x, int y);uint operator %(uint x, uint y);long operator %(long x, long y);ulong operator %(ulong x, ulong y);The result of x % y is the value produced by x – (x / y) * y. If y is zero, aSystem.DivideByZeroException is thrown. The remainder operator never causes an overflow.• Floating-point remainder:float operator %(float x, float y);double operator %(double x, double y);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 and iscomputed as x – n * y, where n is the largest possible integer that is less than or equal to x / y. Thismethod of computing the remainder is analogous to that used for integer operands, but differs from theIEC 60559 definition (in which n is the integer closest to x / y).158

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!