4 #ifndef INCLUDED_RTL_MATH_HXX
5 #define INCLUDED_RTL_MATH_HXX
27 sal_Int32
const * pGroups,
29 bool bEraseTrailingDecZeros =
false)
33 cDecSeparator, pGroups, cGroupSeparator,
34 bEraseTrailingDecZeros);
43 bool bEraseTrailingDecZeros =
false)
47 cDecSeparator, NULL, 0, bEraseTrailingDecZeros);
58 sal_Int32 nDecPlaces,
char cDecSeparator, sal_Int32
const * pGroups,
59 char cGroupSeparator,
bool bEraseTrailingDecZeros =
false)
62 sal_Int32 * pCapacity;
65 pData, pCapacity, rBuffer.
getLength(), fValue, eFormat, nDecPlaces,
66 cDecSeparator, pGroups, cGroupSeparator, bEraseTrailingDecZeros);
76 sal_Int32 nDecPlaces,
char cDecSeparator,
77 bool bEraseTrailingDecZeros =
false)
80 sal_Int32 * pCapacity;
83 pData, pCapacity, rBuffer.
getLength(), fValue, eFormat, nDecPlaces,
84 cDecSeparator, NULL, 0, bEraseTrailingDecZeros);
93 sal_Int32
const * pGroups,
95 bool bEraseTrailingDecZeros =
false)
99 cDecSeparator, pGroups, cGroupSeparator,
100 bEraseTrailingDecZeros);
108 sal_Int32 nDecPlaces,
110 bool bEraseTrailingDecZeros =
false)
114 cDecSeparator, NULL, 0, bEraseTrailingDecZeros);
123 sal_Int32 nDecPlaces,
125 sal_Int32
const * pGroups,
127 bool bEraseTrailingDecZeros =
false)
129 rtl_uString ** pData;
130 sal_Int32 * pCapacity;
133 eFormat, nDecPlaces, cDecSeparator, pGroups,
134 cGroupSeparator, bEraseTrailingDecZeros);
142 sal_Int32 nDecPlaces,
144 bool bEraseTrailingDecZeros =
false)
146 rtl_uString ** pData;
147 sal_Int32 * pCapacity;
150 eFormat, nDecPlaces, cDecSeparator, NULL, 0,
151 bEraseTrailingDecZeros);
156 #ifdef LIBO_INTERNAL_ONLY
158 char cDecSeparator,
char cGroupSeparator,
160 sal_Int32 * pParsedEnd = NULL)
162 char const * pBegin = aString.data();
165 pBegin + aString.size(),
166 cDecSeparator, cGroupSeparator,
168 if (pParsedEnd != NULL)
169 *pParsedEnd =
static_cast<sal_Int32
>(pEnd - pBegin);
174 char cDecSeparator,
char cGroupSeparator,
176 sal_Int32 * pParsedEnd = NULL)
178 char const * pBegin = rString.
getStr();
182 cDecSeparator, cGroupSeparator,
184 if (pParsedEnd != NULL)
185 *pParsedEnd =
static_cast<sal_Int32
>(pEnd - pBegin);
193 #ifdef LIBO_INTERNAL_ONLY
198 sal_Int32 * pParsedEnd = NULL)
203 pBegin + aString.size(),
204 cDecSeparator, cGroupSeparator,
206 if (pParsedEnd != NULL)
207 *pParsedEnd =
static_cast<sal_Int32
>(pEnd - pBegin);
215 sal_Int32 * pParsedEnd = NULL)
221 cDecSeparator, cGroupSeparator,
223 if (pParsedEnd != NULL)
224 *pParsedEnd =
static_cast<sal_Int32
>(pEnd - pBegin);
232 double fValue,
int nDecPlaces = 0,
275 inline double erf(
double fValue)
282 inline double erfc(
double fValue)
318 return (x < 0.0 ? -x : x)
319 < ((a < 0.0 ? -a : a) * (1.0 / (pow(2.0, nPrec))));
334 if ( ((a < 0.0 && b > 0.0) || (b < 0.0 && a > 0.0))
347 if ( ((a < 0.0 && b < 0.0) || (a > 0.0 && b > 0.0)) &&
approxEqual( a, b ) )
374 return SAL_MATH_FINITE(d);
386 return !SAL_MATH_FINITE(d) &&
387 (
reinterpret_cast< sal_math_Double *
>(&d)->inf_parts.fraction_hi == 0)
388 && (
reinterpret_cast< sal_math_Double *
>(&d)->inf_parts.fraction_lo
397 return !SAL_MATH_FINITE(d) && (
398 (
reinterpret_cast< sal_math_Double *
>(&d)->inf_parts.fraction_hi != 0)
399 || (
reinterpret_cast< sal_math_Double *
>(&d)->inf_parts.fraction_lo
407 return reinterpret_cast< sal_math_Double *
>(&d)->inf_parts.sign != 0;
412 inline void setInf(
double * pd,
bool bNegative)
419 md.w32_parts.msw = bNegative ? 0xFFF00000 : 0x7FF00000;
420 md.w32_parts.lsw = 0;
433 md.w32_parts.msw = 0x7FFFFFFF;
434 md.w32_parts.lsw = 0xFFFFFFFF;
450 <= (
static_cast< double >(
static_cast< unsigned long >(0x80000000))
451 *
static_cast< double >(
static_cast< unsigned long >(0x80000000))
457 inline double sin(
double d)
467 inline double cos(
double d)
477 inline double tan(
double d)
489 #endif // INCLUDED_RTL_MATH_HXX
double approxSub(double a, double b)
Subtract two values (a-b).
Definition: math.hxx:345
double round(double fValue, int nDecPlaces=0, rtl_math_RoundingMode eMode=rtl_math_RoundingMode_Corrected)
A wrapper around rtl_math_round.
Definition: math.hxx:231
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: strbuf.hxx:365
double erfc(double fValue)
A wrapper around rtl_math_erfc.
Definition: math.hxx:282
A string buffer implements a mutable sequence of characters.
Definition: strbuf.hxx:51
bool isFinite(double d)
Tests whether a value is neither INF nor NAN.
Definition: math.hxx:372
SAL_DLLPUBLIC double rtl_math_atanh(double fValue) SAL_THROW_EXTERN_C()
Returns more accurate atanh(x) for x near 0 than calculating 0.5*log((1+x)/(1-x)).
SAL_DLLPUBLIC double rtl_math_expm1(double fValue) SAL_THROW_EXTERN_C()
Returns more accurate e^x-1 for x near 0 than calculating directly.
SAL_DLLPUBLIC double rtl_math_log1p(double fValue) SAL_THROW_EXTERN_C()
Returns more accurate log(1+x) for x near 0 than calculating directly.
pData
New string from a character buffer array.
Definition: string.hxx:289
double cos(double d)
Safe cos(), returns NAN if not valid.
Definition: math.hxx:467
double approxCeil(double a)
ceil() method taking approxValue() into account.
Definition: math.hxx:365
double log1p(double fValue)
A wrapper around rtl_math_log1p.
Definition: math.hxx:261
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:182
rtl_math_ConversionStatus
Status for rtl_math_stringToDouble and rtl_math_uStringToDouble.
Definition: math.h:67
SAL_DLLPUBLIC double rtl_math_approxValue(double fValue) SAL_THROW_EXTERN_C()
Rounds value to 15 significant decimal digits.
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:644
void accessInternals(rtl_uString ***pInternalData, sal_Int32 **pInternalCapacity)
Allows access to the internal data of this OUStringBuffer, for effective manipulation.
Definition: ustrbuf.hxx:1355
SAL_DLLPUBLIC double rtl_math_erf(double fValue) SAL_THROW_EXTERN_C()
Returns values of the Errorfunction erf.
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: ustrbuf.hxx:399
sal_uInt16 sal_Unicode
Definition: types.h:103
bool approxEqual(double a, double b)
A wrapper around rtl_math_approxEqual.
Definition: math.hxx:303
bool isValidArcArg(double d)
If a value is a valid argument for sin(), cos(), tan().
Definition: math.hxx:447
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:618
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:196
double asinh(double fValue)
A wrapper around rtl_math_asinh.
Definition: math.hxx:289
rtl::OString doubleToString(double fValue, rtl_math_StringFormat eFormat, sal_Int32 nDecPlaces, char cDecSeparator, sal_Int32 const *pGroups, char cGroupSeparator, bool bEraseTrailingDecZeros=false)
A wrapper around rtl_math_doubleToString.
Definition: math.hxx:24
SAL_DLLPUBLIC double rtl_math_acosh(double fValue) SAL_THROW_EXTERN_C()
Returns values of the inverse hyperbolic cosine.
double tan(double d)
Safe tan(), returns NAN if not valid.
Definition: math.hxx:477
double pow10Exp(double fValue, int nExp)
A wrapper around rtl_math_pow10Exp.
Definition: math.hxx:240
double approxAdd(double a, double b)
Add two values.
Definition: math.hxx:332
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:806
SAL_DLLPUBLIC double rtl_math_erfc(double fValue) SAL_THROW_EXTERN_C()
Returns values of the complement Errorfunction erfc.
void setInf(double *pd, bool bNegative)
Set to +INF if bNegative==false or -INF if bNegative==true.
Definition: math.hxx:412
pData
Definition: ustring.hxx:334
double approxFloor(double a)
floor() method taking approxValue() into account.
Definition: math.hxx:356
SAL_DLLPUBLIC double rtl_math_pow10Exp(double fValue, int nExp) SAL_THROW_EXTERN_C()
Scales fVal to a power of 10 without calling pow() or div() for nExp values between -16 and +16...
bool isSignBitSet(double d)
If the sign bit is set.
Definition: math.hxx:405
SAL_DLLPUBLIC double rtl_math_stringToDouble(char const *pBegin, char const *pEnd, char cDecSeparator, char cGroupSeparator, enum rtl_math_ConversionStatus *pStatus, char const **pParsedEnd) SAL_THROW_EXTERN_C()
Conversion analogous to strtod(), convert a string representing a decimal number into a double value...
void doubleToStringBuffer(rtl::OStringBuffer &rBuffer, double fValue, rtl_math_StringFormat eFormat, sal_Int32 nDecPlaces, char cDecSeparator, sal_Int32 const *pGroups, char cGroupSeparator, bool bEraseTrailingDecZeros=false)
A wrapper around rtl_math_doubleToString that appends to an rtl::OStringBuffer.
Definition: math.hxx:56
double sin(double d)
Safe sin(), returns NAN if not valid.
Definition: math.hxx:457
rtl_math_StringFormat
Formatting modes for rtl_math_doubleToString and rtl_math_doubleToUString and rtl_math_doubleToUStrin...
Definition: math.h:20
double acosh(double fValue)
A wrapper around rtl_math_acosh.
Definition: math.hxx:296
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:784
SAL_DLLPUBLIC void rtl_math_doubleToUString(rtl_uString **pResult, sal_Int32 *pResultCapacity, sal_Int32 nResultOffset, double fValue, enum rtl_math_StringFormat eFormat, sal_Int32 nDecPlaces, sal_Unicode cDecSeparator, sal_Int32 const *pGroups, sal_Unicode cGroupSeparator, sal_Bool bEraseTrailingDecZeros) SAL_THROW_EXTERN_C()
Conversions analogous to sprintf() using internal rounding.
rtl_math_RoundingMode
Rounding modes for rtl_math_round.
Definition: math.h:84
bool isNan(double d)
Test on any QNAN or SNAN.
Definition: math.hxx:394
rtl::OUString doubleToUString(double fValue, rtl_math_StringFormat eFormat, sal_Int32 nDecPlaces, sal_Unicode cDecSeparator, sal_Int32 const *pGroups, sal_Unicode cGroupSeparator, bool bEraseTrailingDecZeros=false)
A wrapper around rtl_math_doubleToUString.
Definition: math.hxx:89
Like HalfUp, but corrects roundoff errors, preferred.
Definition: math.h:88
bool isInf(double d)
If a value represents +INF or -INF.
Definition: math.hxx:383
double approxValue(double fValue)
A wrapper around rtl_math_approxValue.
Definition: math.hxx:247
double expm1(double fValue)
A wrapper around rtl_math_expm1.
Definition: math.hxx:254
void setNan(double *pd)
Set a QNAN.
Definition: math.hxx:426
void doubleToUStringBuffer(rtl::OUStringBuffer &rBuffer, double fValue, rtl_math_StringFormat eFormat, sal_Int32 nDecPlaces, sal_Unicode cDecSeparator, sal_Int32 const *pGroups, sal_Unicode cGroupSeparator, bool bEraseTrailingDecZeros=false)
A wrapper around rtl_math_doubleToUString that appends to an rtl::OUStringBuffer. ...
Definition: math.hxx:121
void accessInternals(rtl_String ***pInternalData, sal_Int32 **pInternalCapacity)
Allows access to the internal data of this OStringBuffer, for effective manipulation.
Definition: strbuf.hxx:1077
SAL_DLLPUBLIC double rtl_math_uStringToDouble(sal_Unicode const *pBegin, sal_Unicode const *pEnd, sal_Unicode cDecSeparator, sal_Unicode cGroupSeparator, enum rtl_math_ConversionStatus *pStatus, sal_Unicode const **pParsedEnd) SAL_THROW_EXTERN_C()
Conversion analogous to strtod(), convert a string representing a decimal number into a double value...
double stringToDouble(rtl::OString const &rString, char cDecSeparator, char cGroupSeparator, rtl_math_ConversionStatus *pStatus=NULL, sal_Int32 *pParsedEnd=NULL)
A wrapper around rtl_math_stringToDouble.
Definition: math.hxx:173
double erf(double fValue)
A wrapper around rtl_math_erf.
Definition: math.hxx:275
SAL_DLLPUBLIC void rtl_math_doubleToString(rtl_String **pResult, sal_Int32 *pResultCapacity, sal_Int32 nResultOffset, double fValue, enum rtl_math_StringFormat eFormat, sal_Int32 nDecPlaces, char cDecSeparator, sal_Int32 const *pGroups, char cGroupSeparator, sal_Bool bEraseTrailingDecZeros) SAL_THROW_EXTERN_C()
Conversions analogous to sprintf() using internal rounding.
double atanh(double fValue)
A wrapper around rtl_math_atanh.
Definition: math.hxx:268
A string buffer implements a mutable sequence of characters.
Definition: ustrbuf.hxx:51
SAL_DLLPUBLIC bool rtl_math_approxEqual(double a, double b) SAL_THROW_EXTERN_C()
Test equality of two values with an accuracy of the magnitude of the given values scaled by 2^-48 (4 ...
SAL_DLLPUBLIC double rtl_math_asinh(double fValue) SAL_THROW_EXTERN_C()
Returns values of the inverse hyperbolic sine.
SAL_DLLPUBLIC double rtl_math_round(double fValue, int nDecPlaces, enum rtl_math_RoundingMode eMode) SAL_THROW_EXTERN_C()
Rounds a double value.