Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Float enhancements #95

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Conversation

essele
Copy link

@essele essele commented Feb 26, 2021

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:

  • support for 18 digit precision
  • proper trailing zero handling for %g
  • removal of all the bit manipulation (mostly because I don't understand it)
  • supports all the bizarre interactions caused by HASH
  • moved zero padding into the _out_rev2 routine (should replace other uses really)

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
Copy link

eyalroz commented Jun 30, 2021

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).

KarlK90 pushed a commit to qmk/printf that referenced this pull request Jul 7, 2022
…` as a default upper bound on buffer sizes, due to the `int` return type of printf()-family functions). Thanks goes to Phillip Johnston <phillip@embeddedartistry.com>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants