Delphi reprint: delphi "div", "mod", "\" division operator differences and use

delphi "div", "mod", "\" operator is the difference between the division and use of

delphi and divide the associated arithmetic operators are: div, mod and the symbol "\", following each of their role, the operand type and the return type for some introduction:
div: for two integers in addition, take supplier, for an operand of type integer, the return value is integer.
\: 2 except for the number, taking providers, and the operand may be a real integer, real type of the return value.
mod: Take the remainder of the division number 2, packet type integer operands, integer return value.
See here, I believe you to their three roles are aware, in order to further facilitate understanding, the following example will be described separately.
var
 A, B, C: Integer;
the begin
  B: =. 5; C: = 2;
  A: div B = C; // this case 2 = A
  A: B = MOD C; // this time. 1 = A
  A: = b \ c; // here at this time to be wrong, think about why.
end;
above a small program the div, mod, \ spend all, since a variable of type integer, and b \ c is a real number type, since the type does not match, so the program will debug a: = b \ c sentence being given, said the following about div and the difference between "\" is:
div to set aside the remainder, as long as the business, such as 5 divided by 2, the quotient is 2, and the remainder is 1, if the words of 5 div 2, the result is equal to 2 .
\ Is in addition to our traditional sense, 4 \ 2 = 2,5 \ 2 = 2.5.
Finally, we must note that, regardless div, mod or "\", the divisor can not be equal to zero. This paper to be in their three delphi division operator presentation.thank

Guess you like

Origin www.cnblogs.com/studycode/p/11622158.html