I'm having a problem when some numbers get to small in my program, because I write them on a file and exponential format gets different: for example, numbers > 1e-100: 0.3979111076224349D-98 smaller numbers: 0.2306878464709676-101 (The D disappears)
And since it is read by another program, those numbers are not read properly.
Currently I'm using the format 3D25.16 A possible solution would be forcing 3E25.15E3 The problem is that I lose 1 digit for any number
I want to avoid losing a digit, and I want to avoid losing performance with tests before printing.
Is there any other solution? The ideal solution for me would be a format that prints exponential with 2 digits on exponent and change to 3 digit when <1e-100 Other good solution would be a format option that transforms very small numbers into zero
Other doubt is: when changing from 3D25.16 to 3E25.15E3 do I lose precision by changing D to E? Because 3D25.15E3 is not accepted
Thank you
As everyone said in the comments (and also you in the question), you can just use E
descriptor instead of D
, so you are allowed to specify the number of digits for the exponent part.
Currently I'm using the format 3D25.16 A possible solution would be forcing 3E25.15E3 The problem is that I lose 1 digit for any number
Well, why not just increase the width of the output with 3E26.15E3
?
Other doubt is: when changing from 3D25.16 to 3E25.15E3 do I lose precision by changing D to E?
With 3E25.15E3
: yes, you possibly do (1 digit). With 3E26.15E3
: no, you don't.