diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-12-17 16:46:17 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-12-17 16:56:35 +0100 |
commit | 695671eb18674ea58103093b9cf31a31afe8d2fd (patch) | |
tree | c88f3f6e37fdab6fabda3dde18f853eacc3dc9d0 /sax | |
parent | 0b2bc82f3cef534d8cab60d8c48a4113abce38cd (diff) |
Avoid inaccurate floating-point computations
...otherwise at least my --disable-dbgutil --disable-debug Linux x86_64 build
failed the CppunitTest_sax_cpputest with 8999999 vs. 9000000 nanoseconds.
Change-Id: I05e0febf413f9f9e01227a0cc4e0f46a5243fe61
Diffstat (limited to 'sax')
-rw-r--r-- | sax/source/tools/converter.cxx | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx index b5c9934636f4..3ebe40cd1598 100644 --- a/sax/source/tools/converter.cxx +++ b/sax/source/tools/converter.cxx @@ -1122,9 +1122,13 @@ bool Converter::convertDuration(util::Duration& rDuration, { if (-1 != nTemp) { - const sal_Int32 nDigits = std::min<sal_Int32>(nPos - nStart, 9); - OSL_ENSURE(nDigits > 0, "bad code monkey: negative digits"); - nNanoSeconds=static_cast<double>(nTemp)*(1000000000.0/pow(10.0,nDigits)); + nNanoSeconds = nTemp; + sal_Int32 nDigits = nPos - nStart; + assert(nDigits >= 0 && nDigits <= 9); + for (; nDigits < 9; ++nDigits) + { + nNanoSeconds *= 10; + } nTemp=-1; if ('S' == string[nPos]) { |