Re: avoiding trailing zeros
- From: Michel Olagnon <molagnon@xxxxxxxxxxxxxxxxx>
- Date: Sat, 20 Dec 2008 10:58:43 +0100
norbert9@xxxxxxxxx wrote:
Is there an edit descriptor in Fortran that suppresses trailing zeros,
but outputs significant digits when not zero?
My (unformatted) output looks typically like
.... 0. 0. 0. 0. 0. 0. 0.7875317755557483 0.7862384282167548
0.784890147719363 ....
Many values are zero, but others are not. To save storage space I
would like it to output
.... 0. 0. 0. 0. 0. 0. 0.7875 0.7862 0.7849 ....
With the edit descriptor f6.4, it would look like
.... 0.0000 0.0000 0.0000 0.0000 0.0000 0.000 0.7875 0.7862
0.7849 ....
which is not space efficient either.
Is there a way to get a fixed number of digits, but avoid the trailing
zeros when the output is exactly zero?
You might write into a string, and replace occurrences of "0 " with " "
until all have disappeared before actually printing the string.
.
- Follow-Ups:
- Re: avoiding trailing zeros
- From: robin
- Re: avoiding trailing zeros
- References:
- avoiding trailing zeros
- From: norbert9
- avoiding trailing zeros
- Prev by Date: Re: Allocating/Deallocating memory for pointers (w/ Code Example)
- Next by Date: Re: gfortran binaries for MinGW-Win32?
- Previous by thread: Re: avoiding trailing zeros
- Next by thread: Re: avoiding trailing zeros
- Index(es):
Relevant Pages
|