涉及整数和实数操作数的算术 [英] Arithmetic involving integer and real operands

查看:143
本文介绍了涉及整数和实数操作数的算术的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Fortran中,涉及整数 real 操作数的算术总是携带 通过将整数操作数转换为与实际操作数相同类型的实际值?或者是否有任何异常?

解决方案

这是在Ch。 7.1.5.1 rel =nofollow > Fortran 2008 Standard

摘自7.15:


 内部运算符类型类型
op x1 x2 [x1] op x2
--------------- -------------------------------------------
II,R ,ZI,R,Z
二进制+, - ,*,/,** RI,R,ZR,R,Z
ZI,R,ZZ,Z,Z

[b]

注意:符号I,R, Z,C和L分别表示整数,实数,
复数,字符和逻辑类型。如果给出了x 2的多个
类型,则操作结果的类型是
,在下一列的相同位置给出。




所以是的,在你的情况下它被转换为 real

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.

这篇关于涉及整数和实数操作数的算术的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆