-
-
Notifications
You must be signed in to change notification settings - Fork 717
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
Conversation
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 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 referencesYour 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 locallyIf 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" |
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. |
Fixed problem with global import of |
There was a problem hiding this 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.
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... |
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.