Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@frederick-vs-ja
Copy link
Contributor

This PR

  • changes the calculation of the exponent part, and
  • handles non-zero tail digits in the integral part even there's no decimal point.

Fixes #1792. Fixes #3161.

- handle non-zero tail digits in the integral part
- change the calculation of the exponent part
@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner April 25, 2023 01:26
@StephanTLavavej StephanTLavavej added the bug Something isn't working label Apr 25, 2023
@StephanTLavavej StephanTLavavej self-assigned this Apr 26, 2023
@StephanTLavavej
Copy link
Member

Thank you! 😻 😻 😻 These changes are exceptionally clean and I pushed only the tiniest of nitpicks.

@StephanTLavavej
Copy link
Member

I'm speculatively mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

Copy link
Contributor

@strega-nil-ms strega-nil-ms left a comment

Choose a reason for hiding this comment

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

Minor change that would be nice for readability, but isn't necessary.

// Adjust _Exponent and _Exponent_adjustment when they have different signedness to avoid overflow.
if (_Exponent > 0 && _Exponent_adjustment < 0) {
if (_Is_hexadecimal) {
const ptrdiff_t _Further_adjustment = (_STD max)(-((_Exponent - 1) / 4 + 1), _Exponent_adjustment);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not worth resetting testing, but it'd be nice in these "_Further_adjustment is negative" cases, to instead negate the other term and use (_STD min); this would imo, make it much clearer what's happening, and you won't be adding and subtracting a negative number.

@StephanTLavavej StephanTLavavej merged commit 091cad2 into microsoft:main Apr 28, 2023
@StephanTLavavej
Copy link
Member

Thanks again so much for investigating and fixing these bugs in my favorite header! 😻 🎉 🚀

@frederick-vs-ja frederick-vs-ja deleted the from_chars-fp-overhaul branch April 29, 2023 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

3 participants