@@ -621,8 +621,8 @@ macro_rules! write_complex {
621
621
let abs_re = if $re < Zero :: zero( ) { $T:: zero( ) - $re. clone( ) } else { $re. clone( ) } ;
622
622
let abs_im = if $im < Zero :: zero( ) { $T:: zero( ) - $im. clone( ) } else { $im. clone( ) } ;
623
623
624
- let mut real: String ;
625
- let mut imag: String ;
624
+ let real: String ;
625
+ let imag: String ;
626
626
627
627
if let Some ( prec) = $f. precision( ) {
628
628
real = format!( concat!( "{:.1$" , $t, "}" ) , abs_re, prec) ;
@@ -642,18 +642,6 @@ macro_rules! write_complex {
642
642
""
643
643
} ;
644
644
645
- if $f. sign_aware_zero_pad( ) && $f. width( ) . is_some( ) {
646
- let total_width = $f. width( ) . unwrap( ) ;
647
- // Subtract leading sign, two prefixes, middle operator and trailing 'i'
648
- // to obtain the width scalars need to be padded to
649
- let subtract = sign. len( ) + prefix. len( ) * 2 + 1 + 1 ;
650
- let scalar_width = total_width - subtract;
651
- let real_width = scalar_width - ( scalar_width/2 ) ;
652
- let imag_width = scalar_width/2 ;
653
- real = format!( "{0:0>1$}" , real, real_width) ;
654
- imag = format!( "{0:0>1$}" , imag, imag_width) ;
655
- }
656
-
657
645
let complex = if $im < Zero :: zero( ) {
658
646
format!( "{}{pre}{re}-{pre}{im}i" , sign, re=real, im=imag, pre=prefix)
659
647
}
@@ -1314,18 +1302,17 @@ mod test {
1314
1302
assert_eq ! ( format!( "{}" , a) , "1.23456+123.456i" ) ;
1315
1303
assert_eq ! ( format!( "{:.2}" , a) , "1.23+123.46i" ) ;
1316
1304
assert_eq ! ( format!( "{:.2e}" , a) , "1.23e0+1.23e2i" ) ;
1317
- assert_eq ! ( format!( "{:+020 .2E}" , a) , "+0001 .23E0+001 .23E2i" ) ;
1305
+ assert_eq ! ( format!( "{:+20 .2E}" , a) , " +1 .23E0+1 .23E2i" ) ;
1318
1306
1319
1307
let b = Complex :: new ( 0x80 , 0xff ) ;
1320
1308
assert_eq ! ( format!( "{:X}" , b) , "80+FFi" ) ;
1321
1309
assert_eq ! ( format!( "{:#x}" , b) , "0x80+0xffi" ) ;
1322
1310
assert_eq ! ( format!( "{:+#b}" , b) , "+0b10000000+0b11111111i" ) ;
1323
1311
assert_eq ! ( format!( "{:+#16o}" , b) , " +0o200+0o377i" ) ;
1324
- assert_eq ! ( format!( "{:+#016x}" , b) , "+0x00080+0x00ffi" ) ;
1325
1312
1326
1313
let c = Complex :: new ( -10 , -10000 ) ;
1327
1314
assert_eq ! ( format!( "{}" , c) , "-10-10000i" ) ;
1328
- assert_eq ! ( format!( "{:016 }" , c) , "-0000010-010000i " ) ;
1315
+ assert_eq ! ( format!( "{:16 }" , c) , " -10-10000i " ) ;
1329
1316
}
1330
1317
1331
1318
#[ test]
0 commit comments