@@ -128,30 +128,375 @@ fn test_format_int_exp_precision() {
128
128
let big_int: u32 = 314_159_265 ;
129
129
assert_eq ! ( format!( "{big_int:.1e}" ) , format!( "{:.1e}" , f64 :: from( big_int) ) ) ;
130
130
131
- //test adding precision
131
+ // test adding precision
132
132
assert_eq ! ( format!( "{:.10e}" , i8 :: MIN ) , "-1.2800000000e2" ) ;
133
133
assert_eq ! ( format!( "{:.10e}" , i16 :: MIN ) , "-3.2768000000e4" ) ;
134
134
assert_eq ! ( format!( "{:.10e}" , i32 :: MIN ) , "-2.1474836480e9" ) ;
135
135
assert_eq ! ( format!( "{:.20e}" , i64 :: MIN ) , "-9.22337203685477580800e18" ) ;
136
136
assert_eq ! ( format!( "{:.40e}" , i128 :: MIN ) , "-1.7014118346046923173168730371588410572800e38" ) ;
137
137
138
- //test rounding
138
+ // test rounding
139
139
assert_eq ! ( format!( "{:.1e}" , i8 :: MIN ) , "-1.3e2" ) ;
140
140
assert_eq ! ( format!( "{:.1e}" , i16 :: MIN ) , "-3.3e4" ) ;
141
141
assert_eq ! ( format!( "{:.1e}" , i32 :: MIN ) , "-2.1e9" ) ;
142
142
assert_eq ! ( format!( "{:.1e}" , i64 :: MIN ) , "-9.2e18" ) ;
143
143
assert_eq ! ( format!( "{:.1e}" , i128 :: MIN ) , "-1.7e38" ) ;
144
144
145
- //test huge precision
145
+ // test huge precision
146
146
assert_eq ! ( format!( "{:.1000e}" , 1 ) , format!( "1.{}e0" , "0" . repeat( 1000 ) ) ) ;
147
147
//test zero precision
148
148
assert_eq ! ( format!( "{:.0e}" , 1 ) , format!( "1e0" , ) ) ;
149
149
assert_eq ! ( format!( "{:.0e}" , 35 ) , format!( "4e1" , ) ) ;
150
150
151
- //test padding with precision (and sign)
151
+ // test padding with precision (and sign)
152
152
assert_eq ! ( format!( "{:+10.3e}" , 1 ) , " +1.000e0" ) ;
153
153
}
154
154
155
+ #[ test]
156
+ fn new_test ( ) {
157
+ // test precision remains correct when rounding to next power
158
+ assert_eq ! ( format!( "{:.1e}" , 999 ) , "1.0e3" ) ;
159
+ assert_eq ! ( format!( "{:.1e}" , 1001 ) , "1.0e3" ) ;
160
+ assert_eq ! ( format!( "{:.1e}" , 1000 ) , "1.0e3" ) ;
161
+ assert_eq ! ( format!( "{:.0e}" , -999 ) , "-1e3" ) ;
162
+ assert_eq ! ( format!( "{:.0e}" , -998 ) , "-1e3" ) ;
163
+ assert_eq ! ( format!( "{:.0e}" , -997 ) , "-1e3" ) ;
164
+ assert_eq ! ( format!( "{:.0e}" , -996 ) , "-1e3" ) ;
165
+ assert_eq ! ( format!( "{:.0e}" , -995 ) , "-1e3" ) ;
166
+ assert_eq ! ( format!( "{:.0e}" , -994 ) , "-1e3" ) ;
167
+ assert_eq ! ( format!( "{:.0e}" , -993 ) , "-1e3" ) ;
168
+ assert_eq ! ( format!( "{:.0e}" , -992 ) , "-1e3" ) ;
169
+ assert_eq ! ( format!( "{:.0e}" , -991 ) , "-1e3" ) ;
170
+ assert_eq ! ( format!( "{:.0e}" , -990 ) , "-1e3" ) ;
171
+ assert_eq ! ( format!( "{:.0e}" , -989 ) , "-1e3" ) ;
172
+ assert_eq ! ( format!( "{:.0e}" , -988 ) , "-1e3" ) ;
173
+ assert_eq ! ( format!( "{:.0e}" , -987 ) , "-1e3" ) ;
174
+ assert_eq ! ( format!( "{:.0e}" , -986 ) , "-1e3" ) ;
175
+ assert_eq ! ( format!( "{:.0e}" , -985 ) , "-1e3" ) ;
176
+ assert_eq ! ( format!( "{:.0e}" , -984 ) , "-1e3" ) ;
177
+ assert_eq ! ( format!( "{:.0e}" , -983 ) , "-1e3" ) ;
178
+ assert_eq ! ( format!( "{:.0e}" , -982 ) , "-1e3" ) ;
179
+ assert_eq ! ( format!( "{:.0e}" , -981 ) , "-1e3" ) ;
180
+ assert_eq ! ( format!( "{:.0e}" , -980 ) , "-1e3" ) ;
181
+ assert_eq ! ( format!( "{:.0e}" , -979 ) , "-1e3" ) ;
182
+ assert_eq ! ( format!( "{:.0e}" , -978 ) , "-1e3" ) ;
183
+ assert_eq ! ( format!( "{:.0e}" , -977 ) , "-1e3" ) ;
184
+ assert_eq ! ( format!( "{:.0e}" , -976 ) , "-1e3" ) ;
185
+ assert_eq ! ( format!( "{:.0e}" , -975 ) , "-1e3" ) ;
186
+ assert_eq ! ( format!( "{:.0e}" , -974 ) , "-1e3" ) ;
187
+ assert_eq ! ( format!( "{:.0e}" , -973 ) , "-1e3" ) ;
188
+ assert_eq ! ( format!( "{:.0e}" , -972 ) , "-1e3" ) ;
189
+ assert_eq ! ( format!( "{:.0e}" , -971 ) , "-1e3" ) ;
190
+ assert_eq ! ( format!( "{:.0e}" , -970 ) , "-1e3" ) ;
191
+ assert_eq ! ( format!( "{:.0e}" , -969 ) , "-1e3" ) ;
192
+ assert_eq ! ( format!( "{:.0e}" , -968 ) , "-1e3" ) ;
193
+ assert_eq ! ( format!( "{:.0e}" , -967 ) , "-1e3" ) ;
194
+ assert_eq ! ( format!( "{:.0e}" , -966 ) , "-1e3" ) ;
195
+ assert_eq ! ( format!( "{:.0e}" , -965 ) , "-1e3" ) ;
196
+ assert_eq ! ( format!( "{:.0e}" , -964 ) , "-1e3" ) ;
197
+ assert_eq ! ( format!( "{:.0e}" , -963 ) , "-1e3" ) ;
198
+ assert_eq ! ( format!( "{:.0e}" , -962 ) , "-1e3" ) ;
199
+ assert_eq ! ( format!( "{:.0e}" , -961 ) , "-1e3" ) ;
200
+ assert_eq ! ( format!( "{:.0e}" , -960 ) , "-1e3" ) ;
201
+ assert_eq ! ( format!( "{:.0e}" , -959 ) , "-1e3" ) ;
202
+ assert_eq ! ( format!( "{:.0e}" , -958 ) , "-1e3" ) ;
203
+ assert_eq ! ( format!( "{:.0e}" , -957 ) , "-1e3" ) ;
204
+ assert_eq ! ( format!( "{:.0e}" , -956 ) , "-1e3" ) ;
205
+ assert_eq ! ( format!( "{:.0e}" , -955 ) , "-1e3" ) ;
206
+ assert_eq ! ( format!( "{:.0e}" , -954 ) , "-1e3" ) ;
207
+ assert_eq ! ( format!( "{:.0e}" , -953 ) , "-1e3" ) ;
208
+ assert_eq ! ( format!( "{:.0e}" , -952 ) , "-1e3" ) ;
209
+ assert_eq ! ( format!( "{:.0e}" , -951 ) , "-1e3" ) ;
210
+ assert_eq ! ( format!( "{:.0e}" , -950 ) , "-1e3" ) ;
211
+ assert_eq ! ( format!( "{:.0e}" , -850 ) , "-9e2" ) ;
212
+ assert_eq ! ( format!( "{:.0e}" , -650 ) , "-7e2" ) ;
213
+ assert_eq ! ( format!( "{:.0e}" , -450 ) , "-5e2" ) ;
214
+ assert_eq ! ( format!( "{:.0e}" , -250 ) , "-3e2" ) ;
215
+ assert_eq ! ( format!( "{:.0e}" , -99 ) , "-1e2" ) ;
216
+ assert_eq ! ( format!( "{:.0e}" , -98 ) , "-1e2" ) ;
217
+ assert_eq ! ( format!( "{:.0e}" , -97 ) , "-1e2" ) ;
218
+ assert_eq ! ( format!( "{:.0e}" , -96 ) , "-1e2" ) ;
219
+ assert_eq ! ( format!( "{:.0e}" , -95 ) , "-1e2" ) ;
220
+ assert_eq ! ( format!( "{:.0e}" , -85 ) , "-9e1" ) ;
221
+ assert_eq ! ( format!( "{:.0e}" , -65 ) , "-7e1" ) ;
222
+ assert_eq ! ( format!( "{:.0e}" , -45 ) , "-5e1" ) ;
223
+ assert_eq ! ( format!( "{:.0e}" , -25 ) , "-3e1" ) ;
224
+ assert_eq ! ( format!( "{:.0e}" , 25 ) , "3e1" ) ;
225
+ assert_eq ! ( format!( "{:.0e}" , 45 ) , "5e1" ) ;
226
+ assert_eq ! ( format!( "{:.0e}" , 65 ) , "7e1" ) ;
227
+ assert_eq ! ( format!( "{:.0e}" , 85 ) , "9e1" ) ;
228
+ assert_eq ! ( format!( "{:.0e}" , 94 ) , "9e1" ) ;
229
+ assert_eq ! ( format!( "{:.0e}" , 95 ) , "1e2" ) ;
230
+ assert_eq ! ( format!( "{:.0e}" , 96 ) , "1e2" ) ;
231
+ assert_eq ! ( format!( "{:.0e}" , 97 ) , "1e2" ) ;
232
+ assert_eq ! ( format!( "{:.0e}" , 98 ) , "1e2" ) ;
233
+ assert_eq ! ( format!( "{:.0e}" , 99 ) , "1e2" ) ;
234
+ assert_eq ! ( format!( "{:.0e}" , 250 ) , "3e2" ) ;
235
+ assert_eq ! ( format!( "{:.0e}" , 450 ) , "5e2" ) ;
236
+ assert_eq ! ( format!( "{:.0e}" , 650 ) , "7e2" ) ;
237
+ assert_eq ! ( format!( "{:.0e}" , 850 ) , "9e2" ) ;
238
+ assert_eq ! ( format!( "{:.0e}" , 950 ) , "1e3" ) ;
239
+ assert_eq ! ( format!( "{:.0e}" , 951 ) , "1e3" ) ;
240
+ assert_eq ! ( format!( "{:.0e}" , 952 ) , "1e3" ) ;
241
+ assert_eq ! ( format!( "{:.0e}" , 953 ) , "1e3" ) ;
242
+ assert_eq ! ( format!( "{:.0e}" , 954 ) , "1e3" ) ;
243
+ assert_eq ! ( format!( "{:.0e}" , 955 ) , "1e3" ) ;
244
+ assert_eq ! ( format!( "{:.0e}" , 956 ) , "1e3" ) ;
245
+ assert_eq ! ( format!( "{:.0e}" , 957 ) , "1e3" ) ;
246
+ assert_eq ! ( format!( "{:.0e}" , 958 ) , "1e3" ) ;
247
+ assert_eq ! ( format!( "{:.0e}" , 959 ) , "1e3" ) ;
248
+ assert_eq ! ( format!( "{:.0e}" , 960 ) , "1e3" ) ;
249
+ assert_eq ! ( format!( "{:.0e}" , 961 ) , "1e3" ) ;
250
+ assert_eq ! ( format!( "{:.0e}" , 962 ) , "1e3" ) ;
251
+ assert_eq ! ( format!( "{:.0e}" , 963 ) , "1e3" ) ;
252
+ assert_eq ! ( format!( "{:.0e}" , 964 ) , "1e3" ) ;
253
+ assert_eq ! ( format!( "{:.0e}" , 965 ) , "1e3" ) ;
254
+ assert_eq ! ( format!( "{:.0e}" , 966 ) , "1e3" ) ;
255
+ assert_eq ! ( format!( "{:.0e}" , 967 ) , "1e3" ) ;
256
+ assert_eq ! ( format!( "{:.0e}" , 968 ) , "1e3" ) ;
257
+ assert_eq ! ( format!( "{:.0e}" , 969 ) , "1e3" ) ;
258
+ assert_eq ! ( format!( "{:.0e}" , 970 ) , "1e3" ) ;
259
+ assert_eq ! ( format!( "{:.0e}" , 971 ) , "1e3" ) ;
260
+ assert_eq ! ( format!( "{:.0e}" , 972 ) , "1e3" ) ;
261
+ assert_eq ! ( format!( "{:.0e}" , 973 ) , "1e3" ) ;
262
+ assert_eq ! ( format!( "{:.0e}" , 974 ) , "1e3" ) ;
263
+ assert_eq ! ( format!( "{:.0e}" , 975 ) , "1e3" ) ;
264
+ assert_eq ! ( format!( "{:.0e}" , 976 ) , "1e3" ) ;
265
+ assert_eq ! ( format!( "{:.0e}" , 977 ) , "1e3" ) ;
266
+ assert_eq ! ( format!( "{:.0e}" , 978 ) , "1e3" ) ;
267
+ assert_eq ! ( format!( "{:.0e}" , 979 ) , "1e3" ) ;
268
+ assert_eq ! ( format!( "{:.0e}" , 980 ) , "1e3" ) ;
269
+ assert_eq ! ( format!( "{:.0e}" , 981 ) , "1e3" ) ;
270
+ assert_eq ! ( format!( "{:.0e}" , 982 ) , "1e3" ) ;
271
+ assert_eq ! ( format!( "{:.0e}" , 983 ) , "1e3" ) ;
272
+ assert_eq ! ( format!( "{:.0e}" , 984 ) , "1e3" ) ;
273
+ assert_eq ! ( format!( "{:.0e}" , 985 ) , "1e3" ) ;
274
+ assert_eq ! ( format!( "{:.0e}" , 986 ) , "1e3" ) ;
275
+ assert_eq ! ( format!( "{:.0e}" , 987 ) , "1e3" ) ;
276
+ assert_eq ! ( format!( "{:.0e}" , 988 ) , "1e3" ) ;
277
+ assert_eq ! ( format!( "{:.0e}" , 989 ) , "1e3" ) ;
278
+ assert_eq ! ( format!( "{:.0e}" , 990 ) , "1e3" ) ;
279
+ assert_eq ! ( format!( "{:.0e}" , 991 ) , "1e3" ) ;
280
+ assert_eq ! ( format!( "{:.0e}" , 992 ) , "1e3" ) ;
281
+ assert_eq ! ( format!( "{:.0e}" , 993 ) , "1e3" ) ;
282
+ assert_eq ! ( format!( "{:.0e}" , 994 ) , "1e3" ) ;
283
+ assert_eq ! ( format!( "{:.0e}" , 995 ) , "1e3" ) ;
284
+ assert_eq ! ( format!( "{:.0e}" , 996 ) , "1e3" ) ;
285
+ assert_eq ! ( format!( "{:.0e}" , 997 ) , "1e3" ) ;
286
+ assert_eq ! ( format!( "{:.0e}" , 998 ) , "1e3" ) ;
287
+ assert_eq ! ( format!( "{:.0e}" , 999 ) , "1e3" ) ;
288
+ assert_eq ! ( format!( "{:.1e}" , -1850 ) , "-1.9e3" ) ;
289
+ assert_eq ! ( format!( "{:.1e}" , -1650 ) , "-1.7e3" ) ;
290
+ assert_eq ! ( format!( "{:.1e}" , -1450 ) , "-1.5e3" ) ;
291
+ assert_eq ! ( format!( "{:.1e}" , -1250 ) , "-1.3e3" ) ;
292
+ assert_eq ! ( format!( "{:.1e}" , -1050 ) , "-1.1e3" ) ;
293
+ assert_eq ! ( format!( "{:.1e}" , -999 ) , "-1.0e3" ) ;
294
+ assert_eq ! ( format!( "{:.1e}" , -998 ) , "-1.0e3" ) ;
295
+ assert_eq ! ( format!( "{:.1e}" , -997 ) , "-1.0e3" ) ;
296
+ assert_eq ! ( format!( "{:.1e}" , -996 ) , "-1.0e3" ) ;
297
+ assert_eq ! ( format!( "{:.1e}" , -995 ) , "-1.0e3" ) ;
298
+ assert_eq ! ( format!( "{:.1e}" , -985 ) , "-9.9e2" ) ;
299
+ assert_eq ! ( format!( "{:.1e}" , -965 ) , "-9.7e2" ) ;
300
+ assert_eq ! ( format!( "{:.1e}" , -945 ) , "-9.5e2" ) ;
301
+ assert_eq ! ( format!( "{:.1e}" , -925 ) , "-9.3e2" ) ;
302
+ assert_eq ! ( format!( "{:.1e}" , -905 ) , "-9.1e2" ) ;
303
+ assert_eq ! ( format!( "{:.1e}" , -885 ) , "-8.9e2" ) ;
304
+ assert_eq ! ( format!( "{:.1e}" , -865 ) , "-8.7e2" ) ;
305
+ assert_eq ! ( format!( "{:.1e}" , -845 ) , "-8.5e2" ) ;
306
+ assert_eq ! ( format!( "{:.1e}" , -825 ) , "-8.3e2" ) ;
307
+ assert_eq ! ( format!( "{:.1e}" , -805 ) , "-8.1e2" ) ;
308
+ assert_eq ! ( format!( "{:.1e}" , -785 ) , "-7.9e2" ) ;
309
+ assert_eq ! ( format!( "{:.1e}" , -765 ) , "-7.7e2" ) ;
310
+ assert_eq ! ( format!( "{:.1e}" , -745 ) , "-7.5e2" ) ;
311
+ assert_eq ! ( format!( "{:.1e}" , -725 ) , "-7.3e2" ) ;
312
+ assert_eq ! ( format!( "{:.1e}" , -705 ) , "-7.1e2" ) ;
313
+ assert_eq ! ( format!( "{:.1e}" , -685 ) , "-6.9e2" ) ;
314
+ assert_eq ! ( format!( "{:.1e}" , -665 ) , "-6.7e2" ) ;
315
+ assert_eq ! ( format!( "{:.1e}" , -645 ) , "-6.5e2" ) ;
316
+ assert_eq ! ( format!( "{:.1e}" , -625 ) , "-6.3e2" ) ;
317
+ assert_eq ! ( format!( "{:.1e}" , -605 ) , "-6.1e2" ) ;
318
+ assert_eq ! ( format!( "{:.1e}" , -585 ) , "-5.9e2" ) ;
319
+ assert_eq ! ( format!( "{:.1e}" , -565 ) , "-5.7e2" ) ;
320
+ assert_eq ! ( format!( "{:.1e}" , -545 ) , "-5.5e2" ) ;
321
+ assert_eq ! ( format!( "{:.1e}" , -525 ) , "-5.3e2" ) ;
322
+ assert_eq ! ( format!( "{:.1e}" , -505 ) , "-5.1e2" ) ;
323
+ assert_eq ! ( format!( "{:.1e}" , -485 ) , "-4.9e2" ) ;
324
+ assert_eq ! ( format!( "{:.1e}" , -465 ) , "-4.7e2" ) ;
325
+ assert_eq ! ( format!( "{:.1e}" , -445 ) , "-4.5e2" ) ;
326
+ assert_eq ! ( format!( "{:.1e}" , -425 ) , "-4.3e2" ) ;
327
+ assert_eq ! ( format!( "{:.1e}" , -405 ) , "-4.1e2" ) ;
328
+ assert_eq ! ( format!( "{:.1e}" , -385 ) , "-3.9e2" ) ;
329
+ assert_eq ! ( format!( "{:.1e}" , -365 ) , "-3.7e2" ) ;
330
+ assert_eq ! ( format!( "{:.1e}" , -345 ) , "-3.5e2" ) ;
331
+ assert_eq ! ( format!( "{:.1e}" , -325 ) , "-3.3e2" ) ;
332
+ assert_eq ! ( format!( "{:.1e}" , -305 ) , "-3.1e2" ) ;
333
+ assert_eq ! ( format!( "{:.1e}" , -285 ) , "-2.9e2" ) ;
334
+ assert_eq ! ( format!( "{:.1e}" , -265 ) , "-2.7e2" ) ;
335
+ assert_eq ! ( format!( "{:.1e}" , -245 ) , "-2.5e2" ) ;
336
+ assert_eq ! ( format!( "{:.1e}" , -225 ) , "-2.3e2" ) ;
337
+ assert_eq ! ( format!( "{:.1e}" , -205 ) , "-2.1e2" ) ;
338
+ assert_eq ! ( format!( "{:.1e}" , -185 ) , "-1.9e2" ) ;
339
+ assert_eq ! ( format!( "{:.1e}" , -165 ) , "-1.7e2" ) ;
340
+ assert_eq ! ( format!( "{:.1e}" , -145 ) , "-1.5e2" ) ;
341
+ assert_eq ! ( format!( "{:.1e}" , -125 ) , "-1.3e2" ) ;
342
+ assert_eq ! ( format!( "{:.1e}" , -105 ) , "-1.1e2" ) ;
343
+ assert_eq ! ( format!( "{:.1e}" , 105 ) , "1.1e2" ) ;
344
+ assert_eq ! ( format!( "{:.1e}" , 125 ) , "1.3e2" ) ;
345
+ assert_eq ! ( format!( "{:.1e}" , 145 ) , "1.5e2" ) ;
346
+ assert_eq ! ( format!( "{:.1e}" , 165 ) , "1.7e2" ) ;
347
+ assert_eq ! ( format!( "{:.1e}" , 185 ) , "1.9e2" ) ;
348
+ assert_eq ! ( format!( "{:.1e}" , 205 ) , "2.1e2" ) ;
349
+ assert_eq ! ( format!( "{:.1e}" , 225 ) , "2.3e2" ) ;
350
+ assert_eq ! ( format!( "{:.1e}" , 245 ) , "2.5e2" ) ;
351
+ assert_eq ! ( format!( "{:.1e}" , 265 ) , "2.7e2" ) ;
352
+ assert_eq ! ( format!( "{:.1e}" , 285 ) , "2.9e2" ) ;
353
+ assert_eq ! ( format!( "{:.1e}" , 305 ) , "3.1e2" ) ;
354
+ assert_eq ! ( format!( "{:.1e}" , 325 ) , "3.3e2" ) ;
355
+ assert_eq ! ( format!( "{:.1e}" , 345 ) , "3.5e2" ) ;
356
+ assert_eq ! ( format!( "{:.1e}" , 365 ) , "3.7e2" ) ;
357
+ assert_eq ! ( format!( "{:.1e}" , 385 ) , "3.9e2" ) ;
358
+ assert_eq ! ( format!( "{:.1e}" , 405 ) , "4.1e2" ) ;
359
+ assert_eq ! ( format!( "{:.1e}" , 425 ) , "4.3e2" ) ;
360
+ assert_eq ! ( format!( "{:.1e}" , 445 ) , "4.5e2" ) ;
361
+ assert_eq ! ( format!( "{:.1e}" , 465 ) , "4.7e2" ) ;
362
+ assert_eq ! ( format!( "{:.1e}" , 485 ) , "4.9e2" ) ;
363
+ assert_eq ! ( format!( "{:.1e}" , 505 ) , "5.1e2" ) ;
364
+ assert_eq ! ( format!( "{:.1e}" , 525 ) , "5.3e2" ) ;
365
+ assert_eq ! ( format!( "{:.1e}" , 545 ) , "5.5e2" ) ;
366
+ assert_eq ! ( format!( "{:.1e}" , 565 ) , "5.7e2" ) ;
367
+ assert_eq ! ( format!( "{:.1e}" , 585 ) , "5.9e2" ) ;
368
+ assert_eq ! ( format!( "{:.1e}" , 605 ) , "6.1e2" ) ;
369
+ assert_eq ! ( format!( "{:.1e}" , 625 ) , "6.3e2" ) ;
370
+ assert_eq ! ( format!( "{:.1e}" , 645 ) , "6.5e2" ) ;
371
+ assert_eq ! ( format!( "{:.1e}" , 665 ) , "6.7e2" ) ;
372
+ assert_eq ! ( format!( "{:.1e}" , 685 ) , "6.9e2" ) ;
373
+ assert_eq ! ( format!( "{:.1e}" , 705 ) , "7.1e2" ) ;
374
+ assert_eq ! ( format!( "{:.1e}" , 725 ) , "7.3e2" ) ;
375
+ assert_eq ! ( format!( "{:.1e}" , 745 ) , "7.5e2" ) ;
376
+ assert_eq ! ( format!( "{:.1e}" , 765 ) , "7.7e2" ) ;
377
+ assert_eq ! ( format!( "{:.1e}" , 785 ) , "7.9e2" ) ;
378
+ assert_eq ! ( format!( "{:.1e}" , 805 ) , "8.1e2" ) ;
379
+ assert_eq ! ( format!( "{:.1e}" , 825 ) , "8.3e2" ) ;
380
+ assert_eq ! ( format!( "{:.1e}" , 845 ) , "8.5e2" ) ;
381
+ assert_eq ! ( format!( "{:.1e}" , 865 ) , "8.7e2" ) ;
382
+ assert_eq ! ( format!( "{:.1e}" , 885 ) , "8.9e2" ) ;
383
+ assert_eq ! ( format!( "{:.1e}" , 905 ) , "9.1e2" ) ;
384
+ assert_eq ! ( format!( "{:.1e}" , 925 ) , "9.3e2" ) ;
385
+ assert_eq ! ( format!( "{:.1e}" , 945 ) , "9.5e2" ) ;
386
+ assert_eq ! ( format!( "{:.1e}" , 965 ) , "9.7e2" ) ;
387
+ assert_eq ! ( format!( "{:.1e}" , 985 ) , "9.9e2" ) ;
388
+ assert_eq ! ( format!( "{:.1e}" , 995 ) , "1.0e3" ) ;
389
+ assert_eq ! ( format!( "{:.1e}" , 996 ) , "1.0e3" ) ;
390
+ assert_eq ! ( format!( "{:.1e}" , 997 ) , "1.0e3" ) ;
391
+ assert_eq ! ( format!( "{:.1e}" , 998 ) , "1.0e3" ) ;
392
+ assert_eq ! ( format!( "{:.1e}" , 999 ) , "1.0e3" ) ;
393
+ assert_eq ! ( format!( "{:.1e}" , 1050 ) , "1.1e3" ) ;
394
+ assert_eq ! ( format!( "{:.1e}" , 1250 ) , "1.3e3" ) ;
395
+ assert_eq ! ( format!( "{:.1e}" , 1450 ) , "1.5e3" ) ;
396
+ assert_eq ! ( format!( "{:.1e}" , 1650 ) , "1.7e3" ) ;
397
+ assert_eq ! ( format!( "{:.1e}" , 1850 ) , "1.9e3" ) ;
398
+ assert_eq ! ( format!( "{:.2e}" , -1985 ) , "-1.99e3" ) ;
399
+ assert_eq ! ( format!( "{:.2e}" , -1965 ) , "-1.97e3" ) ;
400
+ assert_eq ! ( format!( "{:.2e}" , -1945 ) , "-1.95e3" ) ;
401
+ assert_eq ! ( format!( "{:.2e}" , -1925 ) , "-1.93e3" ) ;
402
+ assert_eq ! ( format!( "{:.2e}" , -1905 ) , "-1.91e3" ) ;
403
+ assert_eq ! ( format!( "{:.2e}" , -1885 ) , "-1.89e3" ) ;
404
+ assert_eq ! ( format!( "{:.2e}" , -1865 ) , "-1.87e3" ) ;
405
+ assert_eq ! ( format!( "{:.2e}" , -1845 ) , "-1.85e3" ) ;
406
+ assert_eq ! ( format!( "{:.2e}" , -1825 ) , "-1.83e3" ) ;
407
+ assert_eq ! ( format!( "{:.2e}" , -1805 ) , "-1.81e3" ) ;
408
+ assert_eq ! ( format!( "{:.2e}" , -1785 ) , "-1.79e3" ) ;
409
+ assert_eq ! ( format!( "{:.2e}" , -1765 ) , "-1.77e3" ) ;
410
+ assert_eq ! ( format!( "{:.2e}" , -1745 ) , "-1.75e3" ) ;
411
+ assert_eq ! ( format!( "{:.2e}" , -1725 ) , "-1.73e3" ) ;
412
+ assert_eq ! ( format!( "{:.2e}" , -1705 ) , "-1.71e3" ) ;
413
+ assert_eq ! ( format!( "{:.2e}" , -1685 ) , "-1.69e3" ) ;
414
+ assert_eq ! ( format!( "{:.2e}" , -1665 ) , "-1.67e3" ) ;
415
+ assert_eq ! ( format!( "{:.2e}" , -1645 ) , "-1.65e3" ) ;
416
+ assert_eq ! ( format!( "{:.2e}" , -1625 ) , "-1.63e3" ) ;
417
+ assert_eq ! ( format!( "{:.2e}" , -1605 ) , "-1.61e3" ) ;
418
+ assert_eq ! ( format!( "{:.2e}" , -1585 ) , "-1.59e3" ) ;
419
+ assert_eq ! ( format!( "{:.2e}" , -1565 ) , "-1.57e3" ) ;
420
+ assert_eq ! ( format!( "{:.2e}" , -1545 ) , "-1.55e3" ) ;
421
+ assert_eq ! ( format!( "{:.2e}" , -1525 ) , "-1.53e3" ) ;
422
+ assert_eq ! ( format!( "{:.2e}" , -1505 ) , "-1.51e3" ) ;
423
+ assert_eq ! ( format!( "{:.2e}" , -1485 ) , "-1.49e3" ) ;
424
+ assert_eq ! ( format!( "{:.2e}" , -1465 ) , "-1.47e3" ) ;
425
+ assert_eq ! ( format!( "{:.2e}" , -1445 ) , "-1.45e3" ) ;
426
+ assert_eq ! ( format!( "{:.2e}" , -1425 ) , "-1.43e3" ) ;
427
+ assert_eq ! ( format!( "{:.2e}" , -1405 ) , "-1.41e3" ) ;
428
+ assert_eq ! ( format!( "{:.2e}" , -1385 ) , "-1.39e3" ) ;
429
+ assert_eq ! ( format!( "{:.2e}" , -1365 ) , "-1.37e3" ) ;
430
+ assert_eq ! ( format!( "{:.2e}" , -1345 ) , "-1.35e3" ) ;
431
+ assert_eq ! ( format!( "{:.2e}" , -1325 ) , "-1.33e3" ) ;
432
+ assert_eq ! ( format!( "{:.2e}" , -1305 ) , "-1.31e3" ) ;
433
+ assert_eq ! ( format!( "{:.2e}" , -1285 ) , "-1.29e3" ) ;
434
+ assert_eq ! ( format!( "{:.2e}" , -1265 ) , "-1.27e3" ) ;
435
+ assert_eq ! ( format!( "{:.2e}" , -1245 ) , "-1.25e3" ) ;
436
+ assert_eq ! ( format!( "{:.2e}" , -1225 ) , "-1.23e3" ) ;
437
+ assert_eq ! ( format!( "{:.2e}" , -1205 ) , "-1.21e3" ) ;
438
+ assert_eq ! ( format!( "{:.2e}" , -1185 ) , "-1.19e3" ) ;
439
+ assert_eq ! ( format!( "{:.2e}" , -1165 ) , "-1.17e3" ) ;
440
+ assert_eq ! ( format!( "{:.2e}" , -1145 ) , "-1.15e3" ) ;
441
+ assert_eq ! ( format!( "{:.2e}" , -1125 ) , "-1.13e3" ) ;
442
+ assert_eq ! ( format!( "{:.2e}" , -1105 ) , "-1.11e3" ) ;
443
+ assert_eq ! ( format!( "{:.2e}" , -1085 ) , "-1.09e3" ) ;
444
+ assert_eq ! ( format!( "{:.2e}" , -1065 ) , "-1.07e3" ) ;
445
+ assert_eq ! ( format!( "{:.2e}" , -1045 ) , "-1.05e3" ) ;
446
+ assert_eq ! ( format!( "{:.2e}" , -1025 ) , "-1.03e3" ) ;
447
+ assert_eq ! ( format!( "{:.2e}" , -1005 ) , "-1.01e3" ) ;
448
+ assert_eq ! ( format!( "{:.2e}" , 1005 ) , "1.01e3" ) ;
449
+ assert_eq ! ( format!( "{:.2e}" , 1025 ) , "1.03e3" ) ;
450
+ assert_eq ! ( format!( "{:.2e}" , 1045 ) , "1.05e3" ) ;
451
+ assert_eq ! ( format!( "{:.2e}" , 1065 ) , "1.07e3" ) ;
452
+ assert_eq ! ( format!( "{:.2e}" , 1085 ) , "1.09e3" ) ;
453
+ assert_eq ! ( format!( "{:.2e}" , 1105 ) , "1.11e3" ) ;
454
+ assert_eq ! ( format!( "{:.2e}" , 1125 ) , "1.13e3" ) ;
455
+ assert_eq ! ( format!( "{:.2e}" , 1145 ) , "1.15e3" ) ;
456
+ assert_eq ! ( format!( "{:.2e}" , 1165 ) , "1.17e3" ) ;
457
+ assert_eq ! ( format!( "{:.2e}" , 1185 ) , "1.19e3" ) ;
458
+ assert_eq ! ( format!( "{:.2e}" , 1205 ) , "1.21e3" ) ;
459
+ assert_eq ! ( format!( "{:.2e}" , 1225 ) , "1.23e3" ) ;
460
+ assert_eq ! ( format!( "{:.2e}" , 1245 ) , "1.25e3" ) ;
461
+ assert_eq ! ( format!( "{:.2e}" , 1265 ) , "1.27e3" ) ;
462
+ assert_eq ! ( format!( "{:.2e}" , 1285 ) , "1.29e3" ) ;
463
+ assert_eq ! ( format!( "{:.2e}" , 1305 ) , "1.31e3" ) ;
464
+ assert_eq ! ( format!( "{:.2e}" , 1325 ) , "1.33e3" ) ;
465
+ assert_eq ! ( format!( "{:.2e}" , 1345 ) , "1.35e3" ) ;
466
+ assert_eq ! ( format!( "{:.2e}" , 1365 ) , "1.37e3" ) ;
467
+ assert_eq ! ( format!( "{:.2e}" , 1385 ) , "1.39e3" ) ;
468
+ assert_eq ! ( format!( "{:.2e}" , 1405 ) , "1.41e3" ) ;
469
+ assert_eq ! ( format!( "{:.2e}" , 1425 ) , "1.43e3" ) ;
470
+ assert_eq ! ( format!( "{:.2e}" , 1445 ) , "1.45e3" ) ;
471
+ assert_eq ! ( format!( "{:.2e}" , 1465 ) , "1.47e3" ) ;
472
+ assert_eq ! ( format!( "{:.2e}" , 1485 ) , "1.49e3" ) ;
473
+ assert_eq ! ( format!( "{:.2e}" , 1505 ) , "1.51e3" ) ;
474
+ assert_eq ! ( format!( "{:.2e}" , 1525 ) , "1.53e3" ) ;
475
+ assert_eq ! ( format!( "{:.2e}" , 1545 ) , "1.55e3" ) ;
476
+ assert_eq ! ( format!( "{:.2e}" , 1565 ) , "1.57e3" ) ;
477
+ assert_eq ! ( format!( "{:.2e}" , 1585 ) , "1.59e3" ) ;
478
+ assert_eq ! ( format!( "{:.2e}" , 1605 ) , "1.61e3" ) ;
479
+ assert_eq ! ( format!( "{:.2e}" , 1625 ) , "1.63e3" ) ;
480
+ assert_eq ! ( format!( "{:.2e}" , 1645 ) , "1.65e3" ) ;
481
+ assert_eq ! ( format!( "{:.2e}" , 1665 ) , "1.67e3" ) ;
482
+ assert_eq ! ( format!( "{:.2e}" , 1685 ) , "1.69e3" ) ;
483
+ assert_eq ! ( format!( "{:.2e}" , 1705 ) , "1.71e3" ) ;
484
+ assert_eq ! ( format!( "{:.2e}" , 1725 ) , "1.73e3" ) ;
485
+ assert_eq ! ( format!( "{:.2e}" , 1745 ) , "1.75e3" ) ;
486
+ assert_eq ! ( format!( "{:.2e}" , 1765 ) , "1.77e3" ) ;
487
+ assert_eq ! ( format!( "{:.2e}" , 1785 ) , "1.79e3" ) ;
488
+ assert_eq ! ( format!( "{:.2e}" , 1805 ) , "1.81e3" ) ;
489
+ assert_eq ! ( format!( "{:.2e}" , 1825 ) , "1.83e3" ) ;
490
+ assert_eq ! ( format!( "{:.2e}" , 1845 ) , "1.85e3" ) ;
491
+ assert_eq ! ( format!( "{:.2e}" , 1865 ) , "1.87e3" ) ;
492
+ assert_eq ! ( format!( "{:.2e}" , 1885 ) , "1.89e3" ) ;
493
+ assert_eq ! ( format!( "{:.2e}" , 1905 ) , "1.91e3" ) ;
494
+ assert_eq ! ( format!( "{:.2e}" , 1925 ) , "1.93e3" ) ;
495
+ assert_eq ! ( format!( "{:.2e}" , 1945 ) , "1.95e3" ) ;
496
+ assert_eq ! ( format!( "{:.2e}" , 1965 ) , "1.97e3" ) ;
497
+ assert_eq ! ( format!( "{:.2e}" , 1985 ) , "1.99e3" ) ;
498
+ }
499
+
155
500
#[ test]
156
501
fn test_format_int_zero ( ) {
157
502
assert_eq ! ( format!( "{}" , 0 ) , "0" ) ;
0 commit comments