summaryrefslogtreecommitdiffstatshomepage
path: root/tests/float/float_format.py
Commit message (Collapse)AuthorAge
* py/formatfloat: Use pow(10, e) instead of pos/neg_pow lookup tables.Dan Ellis2022-08-12
| | | | | | | | | | | | | Rework the conversion of floats to decimal strings so it aligns precisely with the conversion of strings to floats in parsenum.c. This is to avoid rendering 1eX as 9.99999eX-1 etc. This is achieved by removing the power- of-10 tables and using pow() to compute the exponent directly, and that's done efficiently by first estimating the power-of-10 exponent from the power-of-2 exponent in the floating-point representation. Code size is reduced by roughly 100 to 200 bytes by this commit. Signed-off-by: Dan Ellis <dan.ellis@gmail.com>
* tests: Format all Python code with black, except tests in basics subdir.David Lechner2020-03-30
| | | | | | | | | | This adds the Python files in the tests/ directory to be formatted with ./tools/codeformat.py. The basics/ subdirectory is excluded for now so we aren't changing too much at once. In a few places `# fmt: off`/`# fmt: on` was used where the code had special formatting for readability or where the test was actually testing the specific formatting.
* py/formatfloat: Fix case where floats could render with negative digits.Damien George2018-03-01
| | | | | | Prior to this patch, some architectures (eg unix x86) could render floats with "negative" digits, like ")". For example, '%.23e' % 1e-80 would come out as "1.0000000000000000/)/(,*0e-80". This patch fixes the known cases.
* py/formatfloat: Fix case where floats could render with a ":" character.Damien George2018-03-01
| | | | | | | Prior to this patch, some architectures (eg unix x86) could render floats with a ":" character in them, eg 1e+39 would come out as ":e+38" (":" is just after "9" in ASCII so this is like 10e+38). This patch fixes some of these cases.
* py/formatfloat: Fix rounding of %f format with edge-case FP values.Damien George2018-03-01
Prior to this patch the %f formatting of some FP values could be off by up to 1, eg '%.0f' % 123 would return "122" (unix x64). Depending on the FP precision (single vs double) certain numbers would format correctly, but others wolud not. This patch should fix all cases of rounding for %f.