From 066e0fe1a230eac2531a53e1ec5fa58347e9e31e Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Wed, 11 Sep 2013 12:20:38 +0200 Subject: let us use the standard library instead of an own pow function Change-Id: Ib1c28fbb5d34409a42b7ea594cde9c1c1cdccdd8 --- unotools/source/misc/datetime.cxx | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) (limited to 'unotools') 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 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(fracNumerator) / static_cast(pow(10, tokFrac.getLength())); + double frac = static_cast(fracNumerator) / pow(static_cast(10), static_cast(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(fracNumerator) / static_cast(pow(10, tokFrac.getLength())); + double frac = static_cast(fracNumerator) / pow(static_cast(10), static_cast(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(fracNumerator) / static_cast(pow(10, tokFrac.getLength())); + double frac = static_cast(fracNumerator) / pow(static_cast(10), static_cast(tokFrac.getLength())); // nanoseconds OSL_ENSURE(frac < 1 && frac >= 0, "ISO8601parse internal error frac seconds (of seconds) not between 0 and 1"); frac *= 1000000000; -- cgit v1.2.3