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

More complete fixes, including integer stuff #96

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

Conversation

essele
Copy link

@essele essele commented Mar 5, 2021

Hi,

Further to my previous pull request, this one also sorts out the duplicate out_rev from the previous pull, but also fixes an issue with integer processing as well.

%#3x would truncate a two digit hex number (because of the 0x) previously which it shouldn't do. This is now fixed.

All tests still pass with the same exceptions as before (one incorrect and one "improved precision" related.)

Lee.

@eyalroz
Copy link

eyalroz commented Jun 30, 2021

Also, is this PR of yours independent from the previous PR?


#if defined(PRINTF_SUPPORT_FLOAT)
//
// This is actually a fairly efficient implementation compared to pow() as it's
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be more time efficient, but it's not more space efficient.

@essele
Copy link
Author

essele commented Jun 30, 2021 via email

@eyalroz
Copy link

eyalroz commented Jun 30, 2021

On my current project, where I’ve worked hard to remove the use of as many standard library math functions as possible, this resulted in a much smaller implementation. The pow() library call depends on a whole set of other complex and large functions which can otherwise be avoided

Yes, but even then - you could use a loop to multiply (you only need ~log(p) steps, not p, if you square each time or square-and-multiply). That's slower than the lookup (typically), but might be smaller. Although TBH I haven't checked the size anywhere. In asymptotic terms you've certainly traded space to gain time, but that depends on how big the compiled multiplication loop ends up being.

@eyalroz
Copy link

eyalroz commented Jun 30, 2021

so I’ve written a different implementation (based on many of the concepts in your great implementation!)

I think you're mistaking me for @mpaland ... I'm just trying to pick up PRs to add to my fork.

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.

2 participants