summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-09-11 12:20:38 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-09-11 15:56:47 +0200
commit066e0fe1a230eac2531a53e1ec5fa58347e9e31e (patch)
treebe7d0c2657099e51ba72fa2ca356b2e91cdc2679 /unotools
parent74cd77b2294ae600576100fdb1b6ba36753c9a00 (diff)
let us use the standard library instead of an own pow function
Change-Id: Ib1c28fbb5d34409a42b7ea594cde9c1c1cdccdd8
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/misc/datetime.cxx29
1 files changed, 3 insertions, 26 deletions
diff --git a/unotools/source/misc/datetime.cxx b/unotools/source/misc/datetime.cxx
index 9119bc37f027..ac42bfe92fd7 100644
--- a/unotools/source/misc/datetime.cxx
+++ b/unotools/source/misc/datetime.cxx
@@ -28,29 +28,6 @@
namespace
{
- sal_Int32 impl_pow(sal_Int32 x, sal_Int32 y)
- {
- if (y == 1)
- return x;
- if ( y % 2 == 0)
- {
- return impl_pow(x*x, y/2);
- }
- else
- {
- return x * impl_pow(x*x, y/2);
- }
- }
- // computes x^y
- sal_Int32 pow(sal_Int32 x, sal_Int32 y)
- {
- if (y < 0)
- throw std::invalid_argument("negative power is not defined in integers");
- if (y == 0)
- return 1;
- return impl_pow(x, y);
- }
-
/** convert string to number with optional min and max values */
template <typename T>
bool convertNumber( T& rValue,
@@ -378,7 +355,7 @@ bool ISO8601parseTime(const OUString &aTimeStr, starutil::Time& rTime)
sal_Int64 fracNumerator;
if ( (bSuccess = convertNumber(fracNumerator, tokFrac)) )
{
- double frac = static_cast<double>(fracNumerator) / static_cast<double>(pow(10, tokFrac.getLength()));
+ double frac = static_cast<double>(fracNumerator) / pow(static_cast<double>(10), static_cast<double>(tokFrac.getLength()));
// minutes
OSL_ENSURE(frac < 1 && frac >= 0, "ISO8601parse internal error frac hours (of hours) not between 0 and 1");
frac *= 60;
@@ -414,7 +391,7 @@ bool ISO8601parseTime(const OUString &aTimeStr, starutil::Time& rTime)
sal_Int64 fracNumerator;
if ( (bSuccess = convertNumber(fracNumerator, tokFrac)) )
{
- double frac = static_cast<double>(fracNumerator) / static_cast<double>(pow(10, tokFrac.getLength()));
+ double frac = static_cast<double>(fracNumerator) / pow(static_cast<double>(10), static_cast<double>(tokFrac.getLength()));
// seconds
OSL_ENSURE(frac < 1 && frac >= 0, "ISO8601parse internal error frac minutes (of minutes) not between 0 and 1");
frac *= 60;
@@ -445,7 +422,7 @@ bool ISO8601parseTime(const OUString &aTimeStr, starutil::Time& rTime)
sal_Int64 fracNumerator;
if ( (bSuccess = convertNumber(fracNumerator, tokFrac)) )
{
- double frac = static_cast<double>(fracNumerator) / static_cast<double>(pow(10, tokFrac.getLength()));
+ double frac = static_cast<double>(fracNumerator) / pow(static_cast<double>(10), static_cast<double>(tokFrac.getLength()));
// nanoseconds
OSL_ENSURE(frac < 1 && frac >= 0, "ISO8601parse internal error frac seconds (of seconds) not between 0 and 1");
frac *= 1000000000;