17 wrt_E (ufloat
* p
, int w
, int d
, int e
, ftnlen len
)
19 char buf
[FMAX
+ EXPMAXDIGS
+ 4], *s
, *se
;
20 int d1
, delta
, e1
, i
, sign
, signspace
;
33 if (f__scale
>= d
+ 2 || f__scale
<= -d
)
38 if (len
== sizeof (real
))
50 signspace
= (int) f__cplus
;
53 dd
= 0.; /* avoid -0 */
56 delta
= w
- (2 /* for the . and the d adjustment above */
57 + 2 /* for the E+ */ + signspace
+ d
+ e
);
59 if (f__scale
<= 0 && delta
> 0)
82 sprintf (buf
, "%#.*E", d
, dd
);
84 /* check for NaN, Infinity */
85 if (!isdigit ((unsigned char) buf
[0]))
91 signspace
= 0; /* no sign for NaNs */
93 delta
= w
- strlen (buf
) - signspace
;
99 PUT (sign
? '-' : '+');
100 for (s
= buf
; *s
; s
++)
106 #ifdef GOOD_SPRINTF_EXPONENT /* When possible, exponent has 2 digits. */
107 if (f__scale
!= 1 && dd
)
108 sprintf (se
, "%+.2d", atoi (se
) + 1 - f__scale
);
111 sprintf (se
, "%+.2d", atoi (se
) + 1 - f__scale
);
122 /* accommodate 3 significant digits in exponent */
127 for (s
-= 2, e1
= 2; s
[0] = s
[1]; s
++);
129 /* Pedantic gives the behavior that Fortran 77 specifies, */
130 /* i.e., requires that E be specified for exponent fields */
131 /* of more than 3 digits. With Pedantic undefined, we get */
132 /* the behavior that Cray displays -- you get a bigger */
133 /* exponent field if it fits. */
137 for (s
-= 2, e1
= 2; (s
[0] = s
[1]); s
++)
140 if ((delta
+= 4) < 0)
154 for (s
+= 2, e1
= 2; *s
; ++e1
, ++s
)
160 PUT (sign
? '-' : '+');
175 else if (f__scale
> 1)
208 wrt_F (ufloat
* p
, int w
, int d
, ftnlen len
)
212 char *b
, buf
[MAXINTDIGS
+ MAXFRACDIGS
+ 4], *s
;
214 x
= (len
== sizeof (real
) ? p
->pf
: p
->pd
);
219 d1
= d
- MAXFRACDIGS
;
249 sprintf (b
= buf
, "%#.*f", d
, x
);
252 n
= sprintf (b
= buf
, "%#.*f", d
, x
) + d1
;
256 if (buf
[0] == '0' && d
)
264 /* check for all zeros */
280 if (sign
|| f__cplus
)
285 if (buf
[0] == '0' && --n
== w
)
295 for (w
-= n
; --w
>= 0;)