Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Comunicados
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.
29285 Discussões

decimal to hexadecimal conversion

tmcole
Principiante
1.918 Visualizações
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 Respostas
sgongola
Principiante
1.918 Visualizações
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.

Jugoslav_Dujic
Contribuidor valorado II
1.918 Visualizações
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
tmcole
Principiante
1.918 Visualizações
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!
Responder