@@ -198,17 +198,9 @@ function _pfmt_f(out::IO, fs::FormatSpec, x::AbstractFloat)
198
198
end
199
199
end
200
200
201
- function _pfmt_floate (out:: IO , sch:: Char , zs:: Integer , u:: Real , prec:: Int , e:: Int , ec:: Char )
201
+ function _pfmt_floate (out:: IO , sch:: Char , zs:: Integer , u:: Real , prec:: Int , e:: Integer , ec:: Char )
202
202
intv = trunc (Integer,u)
203
203
decv = u - intv
204
- if round (Integer, decv * exp10 (prec)) == exp10 (prec)
205
- intv += 1
206
- if intv == 10
207
- intv = 1
208
- e += 1
209
- end
210
- decv = 0.
211
- end
212
204
_pfmt_float (out, sch, zs, intv, decv, prec)
213
205
write (out, ec)
214
206
if e >= 0
@@ -217,9 +209,10 @@ function _pfmt_floate(out::IO, sch::Char, zs::Integer, u::Real, prec::Int, e::In
217
209
write (out, ' -' )
218
210
e = - e
219
211
end
220
- (e1, e2) = divrem (e, 10 )
221
- write (out, Char (' 0' + e1))
222
- write (out, Char (' 0' + e2))
212
+ if e < 10
213
+ write (out, ' 0' )
214
+ end
215
+ _pfmt_intdigits (out, e, _Dec ())
223
216
end
224
217
225
218
@@ -231,15 +224,19 @@ function _pfmt_e(out::IO, fs::FormatSpec, x::AbstractFloat)
231
224
e = 0
232
225
u = zero (x)
233
226
else
234
- e = floor (Integer,log10 (ax)) # exponent
235
- u = ax / exp10 (e) # significand
227
+ rax = signif (ax, fs. prec + 1 )
228
+ e = floor (Integer, log10 (rax)) # exponent
229
+ u = rax / exp10 (e) # significand
236
230
end
237
231
238
232
# calculate length
239
233
xlen = 6 + fs. prec
234
+ if abs (e) > 99
235
+ xlen += _ndigits (abs (e), _Dec ()) - 2
236
+ end
240
237
if sch != ' \0 '
241
238
xlen += 1
242
- end
239
+ end
243
240
244
241
# print
245
242
ec = isupper (fs. typ) ? ' E' : ' e'
0 commit comments