diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-10-24 16:10:26 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-10-24 16:10:54 +0200 |
commit | 6a4b976bd0818c2f60b879594d393baad9a0f346 (patch) | |
tree | abaecbb641e42054fa9af2020fcb205962ccfbb2 /tools | |
parent | e5eb61954d3aff3952244f76cce2c8bfc44e232a (diff) |
Fix Fraction(-2147483648.0) for 32-bit wide long
Change-Id: I6465377de1edff5d0ccc0049fb6d24f6f1223fd2
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qa/cppunit/test_fract.cxx | 7 | ||||
-rw-r--r-- | tools/source/generic/fract.cxx | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/tools/qa/cppunit/test_fract.cxx b/tools/qa/cppunit/test_fract.cxx index bcc6ad2e7aa5..febece099821 100644 --- a/tools/qa/cppunit/test_fract.cxx +++ b/tools/qa/cppunit/test_fract.cxx @@ -90,8 +90,15 @@ public: #endif } + void testMinLongDouble() { + Fraction f(double(SAL_MIN_INT32)); + CPPUNIT_ASSERT_EQUAL(long(SAL_MIN_INT32), f.GetNumerator()); + CPPUNIT_ASSERT_EQUAL(1L, f.GetDenominator()); + } + CPPUNIT_TEST_SUITE(FractionTest); CPPUNIT_TEST(testFraction); + CPPUNIT_TEST(testMinLongDouble); CPPUNIT_TEST_SUITE_END(); }; diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx index 198a42aa2639..7fee117a9a5f 100644 --- a/tools/source/generic/fract.cxx +++ b/tools/source/generic/fract.cxx @@ -136,7 +136,7 @@ Fraction::Fraction( double dVal ) return; } - while ( std::abs( (long)dVal ) < nMAX && nDen < nMAX ) + while ( std::abs( dVal ) < nMAX && nDen < nMAX ) { dVal *= 10; nDen *= 10; |