if self._is_special:
sign = _format_sign(self._sign, spec)
body = str(self.copy_abs())
+ if spec['type'] == '%':
+ body += '%'
return _format_align(sign, body, spec)
# a type of None defaults to 'g' or 'G', depending on context
# issue 6850
('a=-7.0', '0.12345', 'aaaa0.1'),
+
+ # issue 22090
+ ('<^+15.20%', 'inf', '<<+Infinity%<<<'),
+ ('\x07>,%', 'sNaN1234567', 'sNaN1234567%'),
+ ('=10.10%', 'NaN123', ' NaN123%'),
]
for fmt, d, result in test_values:
self.assertEqual(format(Decimal(d), fmt), result)
if (mpd_isspecial(dec)) {
- mem = sizeof "-Infinity";
+ mem = sizeof "-Infinity%";
if (mpd_isnan(dec) && dec->len > 0) {
/* diagnostic code */
mem += dec->digits;
*cp++ = (flags&MPD_FMT_UPPER) ? 'E' : 'e';
cp = exp_to_string(cp, ldigits-dplace);
}
+ }
- if (flags&MPD_FMT_PERCENT) {
- *cp++ = '%';
- }
+ if (flags&MPD_FMT_PERCENT) {
+ *cp++ = '%';
}
assert(cp < decstring+mem);
stackspec.align = '>';
spec = &stackspec;
}
+ if (type == '%') {
+ flags |= MPD_FMT_PERCENT;
+ }
}
else {
uint32_t workstatus = 0;