7.7.1 Multiplication operator
For an operation of the form
y, binary operator overload resolution (Section 7.2.4) 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.
The predefined multiplication operators are listed below. The operators all compute the product of
- Integer multiplication:
int operator *(int x, int y); uint operator *(uint x, uint y); long operator *(long x, long y); ulong operator *(ulong x, ulong y);
checked context, if the product is outside the range of the result type, a
System.OverflowException is thrown. In an
unchecked context, overflows are not reported and any significant high-order bits outside the range of the result type are discarded.
- Floating-point multiplication:
float operator *(float x, float y); double operator *(double x, double y);
The product 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,
y are positive finite values.
z is the result of
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.
- Decimal multiplication:
decimal operator *(decimal x, decimal y);
If the resulting value is too large to represent in the
decimal format, a
System.OverflowException is thrown. If the result value is too small to represent in the
decimal format, the result is zero. The scale of the result, before any rounding, is the sum of the scales of the two operands.
Decimal multiplication is equivalent to using the multiplication operator of type