From: Herman D. Knoble on
Apparently the F90 Standard supports output of the values of
Integer variables in Hexadecimal format(Z format descriptor),
but not the values of Real variables.

That is:
Integer :: x
x=1
write(*,fmt="(1X,Z16)") x
end

is correct. but

Real :: x
x=1.0+Epsilon(x)
write(*,fmt="(1X,Z16)") x
end

is not.

How can one display the internal value of real variables
(in 5 lines or less without depending on compiler extensions)?

Thanks.
Skip Knoble
From: Dan Nagle on
Hi,

Herman D. Knoble wrote:
<snip>

> How can one display the internal value of real variables
> (in 5 lines or less without depending on compiler extensions)?

I suppose the most direct approach is something
along the lines of

transfer( <real-thingo>, <int-thingo>)

with appropriate care to the sizes of things. :-)

--
Cheers!

Dan Nagle
Purple Sage Computing Solutions, Inc.
From: David Flower on

Herman D. Knoble wrote:
> Apparently the F90 Standard supports output of the values of
> Integer variables in Hexadecimal format(Z format descriptor),
> but not the values of Real variables.
>
> That is:
> Integer :: x
> x=1
> write(*,fmt="(1X,Z16)") x
> end
>
> is correct. but
>
> Real :: x
> x=1.0+Epsilon(x)
> write(*,fmt="(1X,Z16)") x
> end
>
> is not.
>
> How can one display the internal value of real variables
> (in 5 lines or less without depending on compiler extensions)?
>
> Thanks.
> Skip Knoble

I know that the powers that be are violently antagonistic to it, but
isn't this a case where the EQUIVALENCE statement is useful:

REAL :: X
INTEGER :: I
EQUIVALENCE ( I, X )
X = 1.0 + Epsilon(X)
WRITE ( *, '(1X,Z16)' ) I

Assuming X and I require the same storage

Dave Flower

From: Joost on

> REAL :: X
> INTEGER :: I
> Assuming X and I require the same storage

which is guaranteed by the standard.

Joost

From: Steven G. Kargl on
In article <1138980959.113819.256110(a)g47g2000cwa.googlegroups.com>,
"Joost" <jv244(a)cam.ac.uk> writes:
>
>> REAL :: X
>> INTEGER :: I
>> Assuming X and I require the same storage
>
> which is guaranteed by the standard.
>

Standard also says that I is undefined though most
compilers will do what the programmer wants.

--
Steve
http://troutmask.apl.washington.edu/~kargl/
 |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8
Prev: fast matrix multiplication
Next: 2 formatting questions