diff --git a/src/generic/spinctlg.cpp b/src/generic/spinctlg.cpp index f9749f052b..830f64f6f0 100644 --- a/src/generic/spinctlg.cpp +++ b/src/generic/spinctlg.cpp @@ -805,8 +805,10 @@ void wxSpinCtrlDouble::ResetTextValidator() /* static */ unsigned wxSpinCtrlDouble::DetermineDigits(double inc) { + // TODO-C++11: Use std::modf() to get the fractional part. inc = fabs(inc); - if ( inc > 0.0 && inc < 1.0 ) + inc -= static_cast(inc); + if ( inc > 0.0 ) { return wxMin(SPINCTRLDBL_MAX_DIGITS, -static_cast(floor(log10(inc)))); } diff --git a/tests/controls/spinctrldbltest.cpp b/tests/controls/spinctrldbltest.cpp index e8a8f32459..c31e83aa84 100644 --- a/tests/controls/spinctrldbltest.cpp +++ b/tests/controls/spinctrldbltest.cpp @@ -236,6 +236,12 @@ TEST_CASE_METHOD(SpinCtrlDoubleTestCase, m_spin->SetIncrement(0.001); m_spin->SetValue(1.23456789); CHECK( m_spin->GetTextValue() == "1.23457" ); + + // Check that using increment greater than 1 also works. + m_spin->SetDigits(0); + m_spin->SetIncrement(2.5); + m_spin->SetValue(7.5); + CHECK( m_spin->GetTextValue() == "7.5" ); } static inline unsigned int GetInitialDigits(double inc)