Print

Print


Aleksandar Donev writes:
 > Hi,
 > I just also included double precision reals in my Radix sort and got a
 > compiler warning for:
 > real(kind=r_64) :: real_64 ! Double-precision on my machine
 > integer(kind=i_64) :: integer_64 ! Also double precision
 > EQUIVALENCE(real_64, integer_64)
 > because double-precision integers are not in the standard set of types. This
 > is somewhat annoying and I don't see a reason for it.

As Richard Maine has pointed out, the standard specifies that a double
precision real takes exactly twice the space of a single precision real.
A single precision real also takes exactly the same space as a default
integer.  Therefore a double precision real takes exactly the same space
as _two_ default integers.

Thus, if you want to transfer double precision to integer(s), equivalence
a double precision variable to _two_ integers, and take the bits out of
them to do your radix sort.  Unfortunately, whether the first or second
of the integers is "high order" is machine dependent, but you can
probably figure out which way it is by adding epsilon to 1.0d0, or
comparing the integers equivalenced to 1.0d0 and 2.0d0.  I'll let
you worry about the meaning of the sign bit of the low order integer.

--
What fraction of Americans believe   |  Van Snyder
Wrestling is real and NASA is fake?  |  [log in to unmask]
Any alleged opinions are my own and have not been approved or disapproved
by JPL, CalTech, NASA, Dan Goldin, George Bush, the Pope, or anybody else.