Suppose I have some variable to double precision, x, that I read from a binary file. When printed this variable x = 384.6433096437924
I want to 'bump' it to quad precision.
integer, parameter :: qp = selected_real_kind(32,307)
integer, parameter :: dp = selected_real_kind(15,307)
real(kind=dp) :: x_double
real(kind=qp) :: x_quad
x_double = 384.6433096437924
x_quad = real(x_double, kind=dp)
print *, x_double, x_quad, 384.64330964379240_qp
This outputs,
384.6433096437924, 384.64330964379240681882947683334351, 384.643309643792400000000000000000009
Which of the quad numbers is the 'best' - i.e. most accurate, consistent etc. value to use? The one with 'junk' or the one without?
I understand (I think!) the issues relating to the exact representation of a float on a computer, but cannot see which is the way to go.
I compile as gfortran -fdefault-real-8