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

Reduce default NumberBox precision to 6 digits #7851

Merged
merged 1 commit into from
Dec 2, 2022

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Oct 19, 2022

Description

printf() defaults to 6 digits. 6 digits are sufficient for most
users under most circumstances, while simultaneously avoiding most
rounding errors for instance during double/float conversion.

Closes #3959

Motivation and Context

FLT_DECIMAL_DIG is 9. With 12 significantly exceeding this,
WinUI is incapable of presenting 32-bit floats. C defaults
to 6 digits for string conversions for this exact reason.

How Has This Been Tested?

Windows Terminal overrides its NumberBoxes the same way this PR does it.

Screenshots (if appropriate):

Before:
YraMDjf6wkUTvhKu

After:
bhvRxhZxbeefgMrL

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Oct 19, 2022
@lhecker lhecker force-pushed the dev/lhecker/number-box-precision branch from b11146f to 246b51f Compare October 19, 2022 17:01
@lhecker lhecker force-pushed the dev/lhecker/number-box-precision branch from 246b51f to f74ce26 Compare October 19, 2022 17:07
@@ -98,7 +98,7 @@ class NumberBox :
bool m_valueUpdating{ false };
bool m_textUpdating{ false };

winrt::SignificantDigitsNumberRounder m_displayRounder{};
winrt::IncrementNumberRounder m_displayRounder{};
Copy link
Member Author

Choose a reason for hiding this comment

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

I initially didn't consider how this would work with >1 integer digit. Switching to a IncrementNumberRounder ensures that it always formats it with 6 fractional digits no matter how many integer digits it has.

@gabbybilka
Copy link
Member

The team will only be taking critical changes into WinUI 2.8 as our current focus is to assist our users in moving from WinUI 2 to WinUI 3. This change did not meet the bar for a WinUI 2.8 servicing release, but is approved to merge into the WinUI 2 main branch for a WinUI 2.9. That being said, at this time, we have no plans for a WinUI 2.9 as we focus on advancing WinUI 3. We will also port this change to WinUI 3 and it will be present for applications that have migrated to WinUI 3 in an upcoming WinAppSDK release.

Thank you for your contribution!

cc: @bpulliam

@bpulliam
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@bpulliam bpulliam removed the needs-triage Issue needs to be triaged by the area owners label Dec 2, 2022
@bpulliam bpulliam merged commit b4e5f2c into microsoft:main Dec 2, 2022
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.

NumberBox has a precision floating point bug
3 participants