Skip to content

Commit

Permalink
Reduce default NumberBox precision to 6 digits (#7851)
Browse files Browse the repository at this point in the history
  • Loading branch information
lhecker authored Dec 2, 2022
1 parent 6a83c31 commit b4e5f2c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions dev/NumberBox/NumberBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ void NumberBox::OnApplyTemplate()

m_isEnabledChangedRevoker = IsEnabledChanged(winrt::auto_revoke, { this, &NumberBox::OnIsEnabledChanged });

// .NET rounds to 12 significant digits when displaying doubles, so we will do the same.
m_displayRounder.SignificantDigits(12);
// 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.
m_displayRounder.Increment(1e-6);

UpdateSpinButtonPlacement();
UpdateSpinButtonEnabled();
Expand Down
2 changes: 1 addition & 1 deletion dev/NumberBox/NumberBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class NumberBox :
bool m_valueUpdating{ false };
bool m_textUpdating{ false };

winrt::SignificantDigitsNumberRounder m_displayRounder{};
winrt::IncrementNumberRounder m_displayRounder{};

tracker_ref<winrt::TextBox> m_textBox{ this };
tracker_ref<winrt::ContentPresenter> m_headerPresenter{ this };
Expand Down

0 comments on commit b4e5f2c

Please sign in to comment.