mpaland / printf

Tiny, fast, non-dependent and fully loaded printf implementation for embedded systems. Extensive test suite passing.
MIT License
2.54k stars 464 forks source link

Float enhancements #95

Open essele opened 3 years ago

essele commented 3 years ago

Hi,

I'm very impressed with your printf implementation .. I've been using it on an embedded project with a great improvement in memory usage.

However, I've recently just added eLua to the project and it uses "%.14g" as it's printed number representation and I noticed that there were quite a few issues with %g and %e support, as well as the 9 digit precision limitation.

Anyway, I've forked it and created a few enhancements to the overall float support, the main changes are:

It passes all the tests apart from two ... one that you have wrong (%0-15.3g) which actually shouldn't have any digits after the decimal place, and the one that checks for 9 digits of precision, since there is now 18.

I've run the tests on a 32bit and 64bit system and the behaviour is the same.

It should be similar in terms of memory consumption and performance, but I haven't run any detailed tests yet.

I do still need to fully replace the out_rev function with out_rev2, I'll work on that next, but thought it would be useful to create a pull request.

Hope this is useful -- very happy to receive any feedback you might have!

Lee.

eyalroz commented 3 years ago

It's a bit difficult to figure out what change regards what issue. And - the commits don't really correspond to the issues, and involve adding and removing code that eventually isn't used. I'd try to clean up the commit history, and quite possibly break up the PR into several smaller PRs (or even - incremental ones).