Commit 3f640ba9 authored by barraclough@apple.com's avatar barraclough@apple.com
Browse files

Windows build fix.

* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* wtf/DecimalNumber.h:
(WTF::DecimalNumber::intPow10):
* wtf/dtoa.cpp:
* wtf/dtoa.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65962 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9a75910c
2010-08-24 Gavin Barraclough <barraclough@apple.com>
Windows build fix.
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* wtf/DecimalNumber.h:
(WTF::DecimalNumber::intPow10):
* wtf/dtoa.cpp:
* wtf/dtoa.h:
2010-08-23 Gavin Barraclough <barraclough@apple.com>
Reviewed by Oliver Hunt.
......
......@@ -126,7 +126,6 @@ EXPORTS
?detach@Debugger@JSC@@UAEXPAVJSGlobalObject@2@@Z
?detachThread@WTF@@YAXI@Z
?didTimeOut@TimeoutChecker@JSC@@QAE_NPAVExecState@2@@Z
?doubleToStringInJavaScriptFormat@WTF@@YAXNQADPAI@Z
?dumpSampleData@JSGlobalData@JSC@@QAEXPAVExecState@2@@Z
?empty@StringImpl@WTF@@SAPAV12@XZ
?enumerable@PropertyDescriptor@JSC@@QBE_NXZ
......@@ -149,6 +148,7 @@ EXPORTS
?number@UString@JSC@@SA?AV12@H@Z
?number@UString@JSC@@SA?AV12@I@Z
?number@UString@JSC@@SA?AV12@N@Z
?numberToString@WTF@@YAINAAY0GA@_W@Z
?functionGetter@PropertySlot@JSC@@ABE?AVJSValue@2@PAVExecState@2@@Z
?functionName@DebuggerCallFrame@JSC@@QBEPBVUString@2@XZ
?get@Structure@JSC@@QAEIPBVStringImpl@WTF@@AAIAAPAVJSCell@2@@Z
......
......@@ -28,6 +28,7 @@
#include <math.h>
#include <wtf/dtoa.h>
#include <wtf/MathExtras.h>
#include <wtf/text/WTFString.h>
namespace WTF {
......@@ -281,6 +282,37 @@ private:
m_precision = significantFigures;
}
double intPow10(int e)
{
// This function uses the "exponentiation by squaring" algorithm and
// long double to quickly and precisely calculate integer powers of 10.0.
// This is a handy workaround for <rdar://problem/4494756>
if (!e)
return 1.0;
bool negative = e < 0;
unsigned exp = negative ? -e : e;
long double result = 10.0;
bool foundOne = false;
for (int bit = 31; bit >= 0; bit--) {
if (!foundOne) {
if ((exp >> bit) & 1)
foundOne = true;
} else {
result = result * result;
if ((exp >> bit) & 1)
result = result * 10.0;
}
}
if (negative)
return static_cast<double>(1.0 / result);
return static_cast<double>(result);
}
bool m_sign;
int m_exponent;
DtoaBuffer m_significand;
......
......@@ -2285,35 +2285,4 @@ ret:
*rve = s;
}
double intPow10(int e)
{
// This function uses the "exponentiation by squaring" algorithm and
// long double to quickly and precisely calculate integer powers of 10.0.
// This is a handy workaround for <rdar://problem/4494756>
if (!e)
return 1.0;
bool negative = e < 0;
unsigned exp = negative ? -e : e;
long double result = 10.0;
bool foundOne = false;
for (int bit = 31; bit >= 0; bit--) {
if (!foundOne) {
if ((exp >> bit) & 1)
foundOne = true;
} else {
result = result * result;
if ((exp >> bit) & 1)
result = result * 10.0;
}
}
if (negative)
return static_cast<double>(1.0 / result);
return static_cast<double>(result);
}
} // namespace WTF
......@@ -35,7 +35,6 @@ double strtod(const char* s00, char** se);
typedef char DtoaBuffer[80];
void dtoa(DtoaBuffer result, double d, int ndigits, int* decpt, int* sign, char** rve);
double intPow10(int);
} // namespace WTF
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment