#ifndef WTF_dtoa_h
#define WTF_dtoa_h
#include "wtf/ASCIICType.h"
#include "wtf/dtoa/double-conversion.h"
#include "wtf/unicode/Unicode.h"
#include "wtf/WTFExport.h"
namespace WTF {
class Mutex;
extern Mutex* s_dtoaP5Mutex;
typedef char DtoaBuffer[80];
WTF_EXPORT void dtoa(DtoaBuffer result, double dd, bool& sign, int& exponent, unsigned& precision);
WTF_EXPORT void dtoaRoundSF(DtoaBuffer result, double dd, int ndigits, bool& sign, int& exponent, unsigned& precision);
WTF_EXPORT void dtoaRoundDP(DtoaBuffer result, double dd, int ndigits, bool& sign, int& exponent, unsigned& precision);
const unsigned NumberToStringBufferLength = 96;
typedef char NumberToStringBuffer[NumberToStringBufferLength];
typedef LChar NumberToLStringBuffer[NumberToStringBufferLength];
WTF_EXPORT const char* numberToString(double, NumberToStringBuffer);
WTF_EXPORT const char* numberToFixedPrecisionString(double, unsigned significantFigures, NumberToStringBuffer, bool truncateTrailingZeros = false);
WTF_EXPORT const char* numberToFixedWidthString(double, unsigned decimalPlaces, NumberToStringBuffer);
WTF_EXPORT double parseDouble(const LChar* string, size_t length, size_t& parsedLength);
WTF_EXPORT double parseDouble(const UChar* string, size_t length, size_t& parsedLength);
namespace Internal {
double parseDoubleFromLongString(const UChar* string, size_t length, size_t& parsedLength);
}
inline double parseDouble(const LChar* string, size_t length, size_t& parsedLength)
{
return double_conversion::StringToDoubleConverter::StringToDouble(reinterpret_cast<const char*>(string), length, &parsedLength);
}
inline double parseDouble(const UChar* string, size_t length, size_t& parsedLength)
{
const size_t conversionBufferSize = 64;
if (length > conversionBufferSize)
return Internal::parseDoubleFromLongString(string, length, parsedLength);
LChar conversionBuffer[conversionBufferSize];
for (int i = 0; i < static_cast<int>(length); ++i)
conversionBuffer[i] = isASCII(string[i]) ? string[i] : 0;
return parseDouble(conversionBuffer, length, parsedLength);
}
}
using WTF::NumberToStringBuffer;
using WTF::NumberToLStringBuffer;
using WTF::numberToString;
using WTF::numberToFixedPrecisionString;
using WTF::numberToFixedWidthString;
using WTF::parseDouble;
#endif