Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

decimal to hexadecimal conversion

tmcole
Beginner
1,913 Views
I am biting the bullet and building my own output for all variables in my code so that I can easily track down differences in variables in order to ensure that changes made to the code do not impact the results. In order to do this, I need all reals output as hexadecimal. Does anyone know an easy way to do this?
0 Kudos
3 Replies
sgongola
Beginner
1,913 Views
Did you look at the Z format descriptor?

The Z data edit descriptor transfers hexadecimal (base 16) values. It takes the following form:

Zw[.m]
The value of m (the minimum number of digits in the constant) must not exceed the value of w (the field width). The m has no effect on input, only output.

The specified I/O list item can be of type integer, real, or logical.

0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,913 Views
Well, moderately easy :-).

real:: f = 2.71828

write(*,"(Z8.8)") TRANSFER(f,1)

Maybe it would work even without TRANSFER (which performs bit-by-bit conversion from 1st argument to type of second argument), but I'm not sure.

Jugoslav
0 Kudos
tmcole
Beginner
1,913 Views
Thanks Jugoslav. Your intuition is correct. I can use the internal write without the TRANSFER function to convert. I was originally hoping to do this but, As usual, the manual is as clear as mud regarding how to do this. Your are a scholar and a gentleman!
0 Kudos
Reply