The arithmetic assignment statement assigns a value to a variable, array element, or record field. If the operands are mixed integer and logical, then the logicals are converted to integers, and the result is an integer. Example: Some combinations of both integer and logical types:ĭATA L1/.TRUE./, L2/.TRUE./, 元/.TRUE./, L4/.TRUE./,įor integer operands with a logical operator, the operation is done bit by bit. ![]() If you use these features, your program may not be portable. The compiler implicitly converts the logical to the appropriate numeric. The numeric can be integer, real, complex, double precision, double complex, or real*16 (SPARC only). You can use a logical value any place where the FORTRAN Standard requires a numeric value. Numeric operations are allowed on logical variables.Any integer operands are promoted to real, and they are then used as the real part of a complex operand, with the imaginary part set to zero. Complex operators apply to only complex operands.Promoting a real operand does not increase the accuracy of the operand. The new least significant bits of the new double precision number are set to zero. Double precision operators apply to only double precision operands, and any operand of lower precision is promoted to double precision.For example, if R is real, and I is integer, then R+I is real. An integer operand mixed with a real operand is promoted to real the fractional part of the new real number is zero. Real operators apply to only real operands, or to combinations of byte, logical, integer, and real operands.There is one extension to this: a logical or byte operand in an arithmetic context is used as an integer. When an INTEGER*8 operand is mixed with REAL*4 operands, the result is REAL*8.Example: An expression that evaluates to zero: Integer operators apply to only integer operands.If there is more than one operator in an expression, then the type of the last operation performed becomes the type of the final value of the expression. ![]() Note these rules for the data type of an expression: Has the type real, because first I is promoted to real, and then the multiplication is performed. LOGICAL*8 dictates only the 8-byte size of the result.Įxample of mixed mode: If R is real, and I is integer, then the expression: Likewise, REAL*4 results if one of the operands is REAL*4, and the other is any of the types between 1-5. For example, INTEGER*8 results if you combine INTEGER*8 and any of the types between 1-5. Note REAL*4, INTEGER*8, and LOGICAL*8 are of the same rank, but they can be the results of different pairs of operands. The operators for an arithmetic expression are any of the following: Structured record field (if it evaluates to a scalar data item) Īn arithmetic expression evaluates to a single arithmetic value, and its operands have the following types. ![]() An operand can be any of the following kinds of data items: The operands indicate what items to apply the action to. The operators indicate what action or operation to perform.
0 Comments
Leave a Reply. |