cosmopolitan/test/libc/stdio
Gabriel Ravier 4754f200ee
Fix printf-family long double prec/rounding issues (#1283)
Currently, in cosmopolitan, there is no handling of the current rounding
mode for long double conversions, such that round-to-nearest gets always
used, regardless of the current rounding mode. %Le also improperly calls
gdtoa with a too small precision (which led to relatively similar bugs).

This patch fixes these issues, in particular by modifying the FPI object
passed to gdtoa such that it is modifiable (so that __fmt can adjust its
rounding field to correspond to FLT_ROUNDS (note that this is not needed
for dtoa, which checks FLT_ROUNDS directly)) and ors STRTOG_Neg into the
kind field in both of the __fmt_dfpbits and __fmt_ldfpbits functions, as
the gdtoa function also depends on it to be able to accurately round any
negative arguments. The change to kind also requires a few other changes
to make sure kind's upper bits (which include STRTOG_Neg) are masked off
when attempting to only examine the lower bits' value. Furthermore, this
patch also makes exactly one change in gdtoa, which appears to be needed
to fix rounding issues with FE_TOWARDZERO (this seems like a gdtoa bug).

The patch also adds a few tests for these issues, along with also taking
the opportunity to clean up some of the previous tests to do the asserts
in the right order (i.e. with the first argument as the expected result,
and the second one being used as the value that it is compared against).
2024-09-07 18:26:04 -07:00
..
BUILD.mk Fix bugs in poll(), select(), ppoll(), and pselect() 2024-09-02 00:29:52 -07:00
crypt_test.c Run clang-format (#1197) 2024-06-01 16:30:43 -04:00
devrand_test.c Run clang-format (#1197) 2024-06-01 16:30:43 -04:00
dirstream_test.c Delete ASAN 2024-06-22 05:45:49 -07:00
dtoa_test.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
dumphexc_test.c Run clang-format (#1197) 2024-06-01 16:30:43 -04:00
ecvt_test.c Fix ecvt/fcvt issues w.r.t. value==0 and ndigit==0 (#1282) 2024-09-07 18:08:11 -07:00
fds_torture_test.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
fgetln_test.c Run clang-format (#1197) 2024-06-01 16:30:43 -04:00
fgets_test.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
fgetwc_test.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
fmemopen_test.c Bring back gc() function 2024-01-08 10:26:28 -08:00
fmt_test.c Support printf %n directive 2024-07-28 22:27:06 -07:00
fprintf_test.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
fputc_test.c Make fread() more consistent with glibc 2024-08-17 02:57:22 -07:00
fputs_test.c Bring back gc() function 2024-01-08 10:26:28 -08:00
fread_test.c Make fread() more consistent with glibc 2024-08-17 02:57:22 -07:00
freopen_test.c Fix fread() with 2gb+ sizes 2024-05-24 19:28:23 -07:00
fscanf_test.c *scanf() fixes to make TeX work (#1109) 2024-02-23 07:15:30 -08:00
fseeko_test.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
ftell_test.c Bring back gc() function 2024-01-08 10:26:28 -08:00
fwrite_test.c Implement proper time zone support 2024-05-04 23:06:37 -07:00
getdelim_test.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
getentropy_test.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
gz_test.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
iconv_test.c Run clang-format (#1197) 2024-06-01 16:30:43 -04:00
joinstrlist_test.c Run clang-format (#1197) 2024-06-01 16:30:43 -04:00
lemur64_test.c Introduce more CTL content 2024-06-27 22:42:32 -07:00
memory_test.c Bring back gc() function 2024-01-08 10:26:28 -08:00
mt19937_test.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
palandprintf_test.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
popen_test.c Improve lock hierarchy 2024-07-24 16:05:48 -07:00
rand_test.c Run clang-format (#1197) 2024-06-01 16:30:43 -04:00
rngset_test.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
snprintf_enomem_test.c Fix printf funcs on memory pressure with floats (#1275) 2024-09-01 14:42:14 -07:00
snprintf_test.c Fix printf-family long double prec/rounding issues (#1283) 2024-09-07 18:26:04 -07:00
sprintf_s.inc flip et / noet in modelines 2023-12-07 22:17:11 -05:00
sprintf_s_test.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
sscanf_test.c *scanf() fixes to make TeX work (#1109) 2024-02-23 07:15:30 -08:00
tmpfile_test.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
ungetc_test.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
vappendf_test.c Run clang-format (#1197) 2024-06-01 16:30:43 -04:00
zipdir_test.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00