Response. Write ("<br>" + 4/3); // 1
The result of Division and Division is an integer.
Division rounds the result to zero, and the absolute value of the result is the maximum possible integer that is smaller than the absolute value of the quotient of the two operands. When the two operand symbols are the same, the result is zero or positive. When the two operand symbols are the opposite, the result is zero or negative.
If the left operand is the smallest value, it can be an int or long value, and the right operand is-1, overflow occurs. Whether the operation occurs in the checked or unchecked context, system. overflowexception is always triggered.
If the value of the right operand is zero, system. dividebyzeroexception is thrown.
Esponse. Write ("<br>" + 5% 2); // 1 obtain the remainder
Response. Write ("<br>" + 4/3.0); // 1.33333333333333
The result is of the double type, precise to 15-16 digits.
This parameter 3.0 is specified as the double type.
Response. Write ("<br>" + 4/3f); // 1.333333
The result is float type, precise to 7 digits.
This parameter 3f is specified as float type.
Appendix:
Both integer and floating point types can be used in an expression. In this case, the integer type is converted to the floating point type. Calculate the expression according to the following rules:
If one of the floating point types is double, the expression is calculated as double or bool (for relational expressions or boolean expressions ).
If the expression does not have the double type, the calculation result of the expression is of the float type, and the relational expression or Boolean expression is of the bool type.