In Fortran, will arithmetic involving an integer and real operand be always carried out by converting the integer operand to a real value of the same kind as the real operand? Or is there any exception?
This is defined in Ch. 7.1.5.1 "Intrinsic operation classification" of the Fortran 2008 Standard:
Excerpt from NOTE 7.15:
Intrinsic operator Type of Type of Type of op x1 x2 [x1] op x2 ---------------------------------------------------------- I I, R, Z I, R, Z Binary +, –, *, /, ** R I, R, Z R, R, Z Z I, R, Z Z, Z, Z[...]
Note: The symbols I, R, Z, C, and L stand for the types integer, real, complex, character, and logical, respectively. Where more than one type for x 2 is given, the type of the result of the operation is given in the same relative position in the next column.
So yes, it is converted to real in your case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With