From e6b5331a36a5815cc36a9b2872f29234efee72cb Mon Sep 17 00:00:00 2001 From: Marco Paland Date: Tue, 21 Aug 2018 12:37:46 +0200 Subject: fix(printf): fix floating point precision limit Return the correct count of precision digits now. Fixes #22 --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index 930207f..eb360fa 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Therefore I decided to write an own, final implementation which meets the follow - Support of decimal/floating number representation (with an own fast itoa/ftoa) - Reentrant and thread-safe, malloc free, no static vars/buffers - LINT and compiler L4 warning free, mature, coverity clean, automotive ready - - Extensive test suite (> 320 test cases) passing + - Extensive test suite (> 330 test cases) passing - Simply the best *printf* around the net - MIT license @@ -167,6 +167,12 @@ int length = sprintf(NULL, "Hello, world"); // length is set to 12 | PRINTF_SUPPORT_PTRDIFF_T | defined | Define this to enable ptrdiff_t (%t) support | +## Caveats +- The internal floating point conversion has a maximum precision of 9 digits. Any higher precision is truncated after the 9th digit and zeros are returned. + So `printf("%.12f", 42.89522312345678)` gives `42.895223123000`. +- Exponential floating point format (e.g. `"%.10e"` to get `1.167e+65`) for large numbers is not supported yet. Sorry. + + ## Test suite For testing just compile, build and run the test suite located in `test/test_suite.cpp`. This uses the [catch](https://github.com/catchorg/Catch2) framework for unit-tests, which is auto-adding main(). Running with the `--wait-for-keypress exit` option waits for the enter key after test end. -- cgit v1.2.3