Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

type precedence protocol... gfortran

Status
Not open for further replies.

zmth

Technical User
Aug 5, 2015
57
PH
i have read that when have mixed types such as integer and real in for example
r=a/i the result will be real*4
but now suppose have set
integer*8 a,r
then will
r=a/i be of precision real*8 or will it just be of default precision real*4 ?
 
integer ofcourse by default
 
or ok i see now why asked. I made an
error in that post. I meant to ask, say

have read that when have mixed types such as integer and real in for example
r=a/i the result will be real*4
but now suppose have set
REAL*8 a,r
then will
r=a/i be of precision real*8 or will it just be of default precision real*4 ?
 
Sorry about the delay in reply. Yes it will.
Code:
program main
    real*4 a4, r4
    real*8 a, r
    integer i
    a = 10.0
    a4 = 10.0
    i = 3
    r = a / i
    r4 = a4 / i
    print *, r4, a4
    print *, r, a
end
These were the results with gfortran. You can always try it for yourself by writing a noddy program. Faster than waiting for an answer

3.33333325 10.0000000
3.3333333333333335 10.000000000000000
 
yea i did try it in gfortran compiler and it did come out to real*8 so now i know
i will not have to go thru and put extra labels such as dble(...) but only in certain places where definitely needed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top