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

Partial replace call to snprintf for '%e' and float or double. #7318

Merged
merged 1 commit into from Feb 7, 2020
Merged

Partial replace call to snprintf for '%e' and float or double. #7318

merged 1 commit into from Feb 7, 2020

Conversation

ghost
Copy link

@ghost ghost commented Dec 14, 2019

This is a followup on #7264 (not yet merged) and #7285 (merged). This time it implements %e and %E specifiers. Part of this is identical to #7264 to make this PR independed.

I run essentially the same tests as in #7264.

Concerning correctness: All tests passed. No exceptions this time.

Concerning speed: For floats the new version is faster, but for doubles numbers with large or small exponent are somewhat problematic. snprintf manages here to get much better results. I've got some ideas on how it might be possible to improve this, but I'd like to postpone this for an extra PR. See pdf-file for some diagrams.

@ghost ghost requested a review from andralex as a code owner December 14, 2019 08:29
@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @berni44! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + phobos#7318"

@ghost
Copy link
Author

ghost commented Dec 16, 2019

I added a description of the three main algorithms in the comments.

For the sake of reviewing I recommend to do %f (PR #7264) first, because the algorithm there is more straight forward (and therefore easier to understand) and the algorithm here builds on that algorithm.

@ghost ghost mentioned this pull request Jan 13, 2020
@ghost
Copy link
Author

ghost commented Jan 14, 2020

Fixed problem with global import of FloatingPointControl. See #7346 for more details.

Copy link
Contributor

@thewilsonator thewilsonator left a comment

Choose a reason for hiding this comment

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

That is a monster of a function. I've a good look over it and in the interests of moving things forward lets merge this.

@dlang-bot dlang-bot merged commit b885f60 into dlang:master Feb 7, 2020
@ghost
Copy link
Author

ghost commented Feb 7, 2020

That is a monster of a function. I've a good look over it and in the interests of moving things forward lets merge this.

First of all: Thanks for doing this.

Well, I havn't found a way to split this into smaller PRs. Maybe it could have been split in one function generating only the digits of the number and an other one taking care of the flags (not sure if that would have a negative impact on speed). But as there are so many of these flags and corner cases I feard, that this would imply a lot of overload handing information from one function to the other.

Having said this: Now I'm quite unsure if you did this because of my posting in the forum or if it was just a coincidence. I believe the former. And I don't know, if you are aware of the similar %f-PR or not. Again I believe the former...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants