Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner

how to assign a double double variable?

Jump to solution

if a double variable is assigned, d0 need to be tailed.

real(8)::a
a=1.2d0

Now, a higher precision variable need to be assigned, what is tailed?

real(16)::b
b=1.2??

 

0 Kudos

Accepted Solutions
Highlighted
Valued Contributor II

real(16)::b

Jump to solution
real(16)::b
b=1.2_16

! or better

integer, parameter :: rk = 16
real(rk) :: b
b = 1.2_rk

 

View solution in original post

0 Kudos
5 Replies
Highlighted
Valued Contributor II
1 View

real(16)::b

Jump to solution
real(16)::b
b=1.2_16

! or better

integer, parameter :: rk = 16
real(rk) :: b
b = 1.2_rk

 

View solution in original post

0 Kudos
Highlighted
Black Belt

Better still (and more

Jump to solution

Better still (and more portable):

Integer, parameter :: qk = selected_real_kind(30)
real(qk)::b
b=1.2_qk

 

--
Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
Beginner

Quote:Steve Lionel (Ret.)

Jump to solution

Steve Lionel (Ret.) wrote:

Better still (and more portable):

Integer, parameter :: qk = selected_real_kind(30)
real(qk)::b
b=1.2_qk

 

thx!!

Then, what forms of functions such as dsqrt is?

0 Kudos
Highlighted
Black Belt

Quote:仁义 许. wrote: Then, what

Jump to solution

仁义 许. wrote:
 Then, what forms of functions such as dsqrt is? 

DSQRT is a specific function (more than one function for one purpose, one for each type of argument). Fortran77 and earlier versions of Fortran had plenty of such specific functions. Fortran 90 and later versions provide generic functions, so that you can use a single function name regardless of the type of the argument and function value. It is recommended that you do not use specific functions such as DSQRT in new code.

0 Kudos
Highlighted
Black Belt

RIght - just use the generic

Jump to solution

RIght - just use the generic SQRT.

--
Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos