Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29276 Discussions

printing fractions without leading zeros?

Intel_C_Intel
Employee
510 Views

I have old outputs using MS fortran 5.1 for DOS where fractions are printed without leading zeros, e.g. .45.

My IVF 9.1.034 prints with leading zeros, e.g. 0.45.

Is there a way for IVF to print without leading zeros (forautomated output comparisons)?

Thank you,

Yair

0 Kudos
3 Replies
Steven_L_Intel1
Employee
510 Views
No, sorry. The Fortran standard makes the leading zero for fractions optional. Most implementations display it, but Microsoft's did not. This is not under user control.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
510 Views
Instead, you can investigate diff tools mentioned e.g. here, (ndiff or numdiff), which can supposedly overcome the problems of small numeric differences (apart from just the leading zeroes). Disclaimer: I haven't used any of those so I can't comment on reliability or usability.
0 Kudos
jimdempseyatthecove
Honored Contributor III
510 Views

To be portable you will have to write edit function that takes a real and format, write to internal record, remove potential leading zero, return string.

Jim

0 Kudos
Reply