mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-30 19:17:36 +00:00
Support %lf and %lF in format string
Per C99 this should resolve to double.
This commit is contained in:
parent
35c7edac49
commit
5d334b9ce0
2 changed files with 5 additions and 0 deletions
|
@ -215,6 +215,10 @@ hidden int palandprintf(void *fn, void *arg, const char *format, va_list va) {
|
|||
signbit = sizeof(intmax_t) * 8 - 1;
|
||||
break;
|
||||
case 'l':
|
||||
if (format[1] == 'f' || format[1] == 'F') {
|
||||
format++;
|
||||
break;
|
||||
}
|
||||
if (format[1] == 'l') format++;
|
||||
/* fallthrough */
|
||||
case 't': /* ptrdiff_t */
|
||||
|
|
|
@ -421,6 +421,7 @@ TEST(sprintf, test_float) {
|
|||
EXPECT_STREQ("+42.90", Format("%+6.2f", 42.8952));
|
||||
EXPECT_STREQ("+42.9", Format("%+5.1f", 42.9252));
|
||||
EXPECT_STREQ("42.500000", Format("%f", 42.5));
|
||||
EXPECT_STREQ("42.500000", Format("%lf", 42.5));
|
||||
EXPECT_STREQ("42.5", Format("%.1f", 42.5));
|
||||
EXPECT_STREQ("42167.000000", Format("%f", 42167.0));
|
||||
EXPECT_STREQ("-12345.987654321", Format("%.9f", -12345.987654321));
|
||||
|
|
Loading…
Reference in a new issue