Hallo everybody,
I am using a code (compiled with gfortran)
which uses the selected_real_kind statement, however
since I had problems I tried to implement a very basic code like:
!-----------------------------------------------
program real_kinds
implicit none
integer,parameter :: p16 = selected_real_kind(p =16)
real ( kind = p16 ) :: b,c
! 12345678901
b = 0.33333333222
c = 0.33333333999
if (c.ne.b) write(*,*) 'not equal'
if (c.eq.b) write(*,*) ' equal'
end program
!-----------------------------------------------------------------
when I run this program the result is that c and b are equal.
In my understanding of "selected_real_kind" statement they should be different.
I also tried to have a quadruple precision with
real ( kind = 16 ) :: b,c
but the compiler (gfortran) returns an error:
Error: Kind 16 not supported for type REAL at (1)
I suppose my error is very trivial however I don't understand what's going on! How do I implement higher precision?
thank you for the help,
cheers,
Paolo
I am using a code (compiled with gfortran)
which uses the selected_real_kind statement, however
since I had problems I tried to implement a very basic code like:
!-----------------------------------------------
program real_kinds
implicit none
integer,parameter :: p16 = selected_real_kind(p =16)
real ( kind = p16 ) :: b,c
! 12345678901
b = 0.33333333222
c = 0.33333333999
if (c.ne.b) write(*,*) 'not equal'
if (c.eq.b) write(*,*) ' equal'
end program
!-----------------------------------------------------------------
when I run this program the result is that c and b are equal.
In my understanding of "selected_real_kind" statement they should be different.
I also tried to have a quadruple precision with
real ( kind = 16 ) :: b,c
but the compiler (gfortran) returns an error:
Error: Kind 16 not supported for type REAL at (1)
I suppose my error is very trivial however I don't understand what's going on! How do I implement higher precision?
thank you for the help,
cheers,
Paolo