1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #if !defined INCLUDED_RTL_MATH_H 29*cdf0e10cSrcweir #define INCLUDED_RTL_MATH_H 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "rtl/ustring.h" 32*cdf0e10cSrcweir #include "sal/types.h" 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #if defined __cplusplus 35*cdf0e10cSrcweir extern "C" { 36*cdf0e10cSrcweir #endif /* __cplusplus */ 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir /** Formatting modes for rtl_math_doubleToString and rtl_math_doubleToUString 39*cdf0e10cSrcweir and rtl_math_doubleToUStringBuffer. 40*cdf0e10cSrcweir */ 41*cdf0e10cSrcweir enum rtl_math_StringFormat 42*cdf0e10cSrcweir { 43*cdf0e10cSrcweir /** Like sprintf() %E. 44*cdf0e10cSrcweir */ 45*cdf0e10cSrcweir rtl_math_StringFormat_E, 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir /** Like sprintf() %f. 48*cdf0e10cSrcweir */ 49*cdf0e10cSrcweir rtl_math_StringFormat_F, 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir /** Like sprintf() %G, 'F' or 'E' format is used depending on which one is 52*cdf0e10cSrcweir more compact. 53*cdf0e10cSrcweir */ 54*cdf0e10cSrcweir rtl_math_StringFormat_G, 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir /** Automatic, 'F' or 'E' format is used depending on the numeric value to 57*cdf0e10cSrcweir be formatted. 58*cdf0e10cSrcweir */ 59*cdf0e10cSrcweir rtl_math_StringFormat_Automatic, 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir /** @internal 62*cdf0e10cSrcweir */ 63*cdf0e10cSrcweir rtl_math_StringFormat_FORCE_EQUAL_SIZE = SAL_MAX_ENUM 64*cdf0e10cSrcweir }; 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir /** Status for rtl_math_stringToDouble and rtl_math_uStringToDouble. 67*cdf0e10cSrcweir */ 68*cdf0e10cSrcweir enum rtl_math_ConversionStatus 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir /** Conversion was successful. 71*cdf0e10cSrcweir */ 72*cdf0e10cSrcweir rtl_math_ConversionStatus_Ok, 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir /** Conversion caused overflow or underflow. 75*cdf0e10cSrcweir */ 76*cdf0e10cSrcweir rtl_math_ConversionStatus_OutOfRange, 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir /** @internal 79*cdf0e10cSrcweir */ 80*cdf0e10cSrcweir rtl_math_ConversionStatus_FORCE_EQUAL_SIZE = SAL_MAX_ENUM 81*cdf0e10cSrcweir }; 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir /** Rounding modes for rtl_math_round. 84*cdf0e10cSrcweir */ 85*cdf0e10cSrcweir enum rtl_math_RoundingMode 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir /** Like HalfUp, but corrects roundoff errors, preferred. 88*cdf0e10cSrcweir */ 89*cdf0e10cSrcweir rtl_math_RoundingMode_Corrected, 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir /** Floor of absolute value, signed return (commercial). 92*cdf0e10cSrcweir */ 93*cdf0e10cSrcweir rtl_math_RoundingMode_Down, 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir /** Ceil of absolute value, signed return (commercial). 96*cdf0e10cSrcweir */ 97*cdf0e10cSrcweir rtl_math_RoundingMode_Up, 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir /** Floor of signed value. 100*cdf0e10cSrcweir */ 101*cdf0e10cSrcweir rtl_math_RoundingMode_Floor, 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir /** Ceil of signed value. 104*cdf0e10cSrcweir */ 105*cdf0e10cSrcweir rtl_math_RoundingMode_Ceiling, 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir /** Frac <= 0.5 ? floor of abs : ceil of abs, signed return. 108*cdf0e10cSrcweir */ 109*cdf0e10cSrcweir rtl_math_RoundingMode_HalfDown, 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir /** Frac < 0.5 ? floor of abs : ceil of abs, signed return (mathematical). 112*cdf0e10cSrcweir */ 113*cdf0e10cSrcweir rtl_math_RoundingMode_HalfUp, 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir /** IEEE rounding mode (statistical). 116*cdf0e10cSrcweir */ 117*cdf0e10cSrcweir rtl_math_RoundingMode_HalfEven, 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir /** @internal 120*cdf0e10cSrcweir */ 121*cdf0e10cSrcweir rtl_math_RoundingMode_FORCE_EQUAL_SIZE = SAL_MAX_ENUM 122*cdf0e10cSrcweir }; 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir /** Special decimal places constants for rtl_math_doubleToString and 125*cdf0e10cSrcweir rtl_math_doubleToUString and rtl_math_doubleToUStringBuffer. 126*cdf0e10cSrcweir */ 127*cdf0e10cSrcweir enum rtl_math_DecimalPlaces 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir /** Value to be used with rtl_math_StringFormat_Automatic. 130*cdf0e10cSrcweir */ 131*cdf0e10cSrcweir rtl_math_DecimalPlaces_Max = 0x7ffffff, 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir /** Value to be used with rtl_math_StringFormat_G. 134*cdf0e10cSrcweir In fact the same value as rtl_math_DecimalPlaces_Max, just an alias for 135*cdf0e10cSrcweir better understanding. 136*cdf0e10cSrcweir */ 137*cdf0e10cSrcweir rtl_math_DecimalPlaces_DefaultSignificance = 0x7ffffff 138*cdf0e10cSrcweir }; 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir /** Conversions analogous to sprintf() using internal rounding. 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir +/-HUGE_VAL are converted to "INF" and "-INF", NAN values are 144*cdf0e10cSrcweir converted to "NaN". 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir @param pResult 147*cdf0e10cSrcweir Returns the resulting byte string. Must itself not be null, and must point 148*cdf0e10cSrcweir to either null or a valid string. 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir @param pResultCapacity 151*cdf0e10cSrcweir If null, pResult is considered to point to immutable strings, and a new 152*cdf0e10cSrcweir string will be allocated in pResult. 153*cdf0e10cSrcweir If non-null, it points to the current capacity of pResult, which is 154*cdf0e10cSrcweir considered to point to a string buffer (pResult must not itself be null in 155*cdf0e10cSrcweir this case, and must point to a string that has room for the given capacity). 156*cdf0e10cSrcweir The string representation of the given double value is inserted into pResult 157*cdf0e10cSrcweir at position nResultOffset. If pResult's current capacity is too small, a 158*cdf0e10cSrcweir new string buffer will be allocated in pResult as necessary, and 159*cdf0e10cSrcweir pResultCapacity will contain the new capacity on return. 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir @param nResultOffset 162*cdf0e10cSrcweir If pResult is used as a string buffer (i.e., pResultCapacity is non-null), 163*cdf0e10cSrcweir nResultOffset specifies the insertion offset within the buffer. Ignored 164*cdf0e10cSrcweir otherwise. 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir @param fValue 167*cdf0e10cSrcweir The value to convert. 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir @param eFormat 170*cdf0e10cSrcweir The format to use, one of rtl_math_StringFormat. 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir @param nDecPlaces 173*cdf0e10cSrcweir The number of decimals to be generated. Effectively fValue is rounded at 174*cdf0e10cSrcweir this position, specifying nDecPlaces <= 0 accordingly rounds the value 175*cdf0e10cSrcweir before the decimal point and fills with zeros. 176*cdf0e10cSrcweir If eFormat == rtl_math_StringFormat_Automatic and nDecPlaces == 177*cdf0e10cSrcweir rtl_math_DecimalPlaces_Max, the highest number of significant decimals 178*cdf0e10cSrcweir possible is generated. 179*cdf0e10cSrcweir If eFormat == rtl_math_StringFormat_G, nDecPlaces specifies the number of 180*cdf0e10cSrcweir significant digits instead. If nDecPlaces == 181*cdf0e10cSrcweir rtl_math_DecimalPlaces_DefaultSignificance, the default number (currently 6 182*cdf0e10cSrcweir as implemented by most libraries) of significant digits is generated. 183*cdf0e10cSrcweir According to the ANSI C90 standard the E style will be used only if the 184*cdf0e10cSrcweir exponent resulting from the conversion is less than -4 or greater than or 185*cdf0e10cSrcweir equal to the precision. However, as opposed to the ANSI standard, trailing 186*cdf0e10cSrcweir zeros are not necessarily removed from the fractional portion of the result 187*cdf0e10cSrcweir unless bEraseTrailingDecZeros == true was specified. 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir @param cDecSeparator 190*cdf0e10cSrcweir The decimal separator. 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir @param pGroups 193*cdf0e10cSrcweir Either null (no grouping is used), or a null-terminated list of group 194*cdf0e10cSrcweir lengths. Each group length must be strictly positive. If the number of 195*cdf0e10cSrcweir digits in a conversion exceeds the specified range, the last (highest) group 196*cdf0e10cSrcweir length is repeated as needed. Values are applied from right to left, for a 197*cdf0e10cSrcweir grouping of 1,00,00,000 you'd have to specify pGroups={3,2,0}. 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir @param cGroupSeparator 200*cdf0e10cSrcweir The group separator. Ignored if pGroups is null. 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir @param bEraseTrailingDecZeros 203*cdf0e10cSrcweir Trailing zeros in decimal places are erased. 204*cdf0e10cSrcweir */ 205*cdf0e10cSrcweir void SAL_CALL rtl_math_doubleToString(rtl_String ** pResult, 206*cdf0e10cSrcweir sal_Int32 * pResultCapacity, 207*cdf0e10cSrcweir sal_Int32 nResultOffset, double fValue, 208*cdf0e10cSrcweir enum rtl_math_StringFormat eFormat, 209*cdf0e10cSrcweir sal_Int32 nDecPlaces, 210*cdf0e10cSrcweir sal_Char cDecSeparator, 211*cdf0e10cSrcweir sal_Int32 const * pGroups, 212*cdf0e10cSrcweir sal_Char cGroupSeparator, 213*cdf0e10cSrcweir sal_Bool bEraseTrailingDecZeros) 214*cdf0e10cSrcweir SAL_THROW_EXTERN_C(); 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir /** Conversions analogous to sprintf() using internal rounding. 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir +/-HUGE_VAL are converted to "INF" and "-INF", NAN values are 219*cdf0e10cSrcweir converted to "NaN". 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir @param pResult 222*cdf0e10cSrcweir Returns the resulting Unicode string. Must itself not be null, and must 223*cdf0e10cSrcweir point to either null or a valid string. 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir @param pResultCapacity 226*cdf0e10cSrcweir If null, pResult is considered to point to immutable strings, and a new 227*cdf0e10cSrcweir string will be allocated in pResult. 228*cdf0e10cSrcweir If non-null, it points to the current capacity of pResult, which is 229*cdf0e10cSrcweir considered to point to a string buffer (pResult must not itself be null in 230*cdf0e10cSrcweir this case, and must point to a string that has room for the given capacity). 231*cdf0e10cSrcweir The string representation of the given double value is inserted into pResult 232*cdf0e10cSrcweir at position nResultOffset. If pResult's current capacity is too small, a 233*cdf0e10cSrcweir new string buffer will be allocated in pResult as necessary, and 234*cdf0e10cSrcweir pResultCapacity will contain the new capacity on return. 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir @param nResultOffset 237*cdf0e10cSrcweir If pResult is used as a string buffer (i.e., pResultCapacity is non-null), 238*cdf0e10cSrcweir nResultOffset specifies the insertion offset within the buffer. Ignored 239*cdf0e10cSrcweir otherwise. 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir @param fValue 242*cdf0e10cSrcweir The value to convert. 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir @param eFormat 245*cdf0e10cSrcweir The format to use, one of rtl_math_StringFormat. 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir @param nDecPlaces 248*cdf0e10cSrcweir The number of decimals to be generated. Effectively fValue is rounded at 249*cdf0e10cSrcweir this position, specifying nDecPlaces <= 0 accordingly rounds the value 250*cdf0e10cSrcweir before the decimal point and fills with zeros. 251*cdf0e10cSrcweir If eFormat == rtl_math_StringFormat_Automatic and nDecPlaces == 252*cdf0e10cSrcweir rtl_math_DecimalPlaces_Max, the highest number of significant decimals 253*cdf0e10cSrcweir possible is generated. 254*cdf0e10cSrcweir If eFormat == rtl_math_StringFormat_G, nDecPlaces specifies the number of 255*cdf0e10cSrcweir significant digits instead. If nDecPlaces == 256*cdf0e10cSrcweir rtl_math_DecimalPlaces_DefaultSignificance, the default number (currently 6 257*cdf0e10cSrcweir as implemented by most libraries) of significant digits is generated. 258*cdf0e10cSrcweir According to the ANSI C90 standard the E style will be used only if the 259*cdf0e10cSrcweir exponent resulting from the conversion is less than -4 or greater than or 260*cdf0e10cSrcweir equal to the precision. However, as opposed to the ANSI standard, trailing 261*cdf0e10cSrcweir zeros are not necessarily removed from the fractional portion of the result 262*cdf0e10cSrcweir unless bEraseTrailingDecZeros == true was specified. 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir @param cDecSeparator 265*cdf0e10cSrcweir The decimal separator. 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir @param pGroups 268*cdf0e10cSrcweir Either null (no grouping is used), or a null-terminated list of group 269*cdf0e10cSrcweir lengths. Each group length must be strictly positive. If the number of 270*cdf0e10cSrcweir digits in a conversion exceeds the specified range, the last (highest) group 271*cdf0e10cSrcweir length is repeated as needed. Values are applied from right to left, for a 272*cdf0e10cSrcweir grouping of 1,00,00,000 you'd have to specify pGroups={3,2,0}. 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir @param cGroupSeparator 275*cdf0e10cSrcweir The group separator. Ignored if pGroups is null. 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir @param bEraseTrailingDecZeros 278*cdf0e10cSrcweir Trailing zeros in decimal places are erased. 279*cdf0e10cSrcweir */ 280*cdf0e10cSrcweir void SAL_CALL rtl_math_doubleToUString(rtl_uString ** pResult, 281*cdf0e10cSrcweir sal_Int32 * pResultCapacity, 282*cdf0e10cSrcweir sal_Int32 nResultOffset, double fValue, 283*cdf0e10cSrcweir enum rtl_math_StringFormat eFormat, 284*cdf0e10cSrcweir sal_Int32 nDecPlaces, 285*cdf0e10cSrcweir sal_Unicode cDecSeparator, 286*cdf0e10cSrcweir sal_Int32 const * pGroups, 287*cdf0e10cSrcweir sal_Unicode cGroupSeparator, 288*cdf0e10cSrcweir sal_Bool bEraseTrailingDecZeros) 289*cdf0e10cSrcweir SAL_THROW_EXTERN_C(); 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir /** Conversion analogous to strtod(), convert a string representing a 292*cdf0e10cSrcweir decimal number into a double value. 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir Leading tabs (0x09) and spaces (0x20) are eaten. Overflow returns 295*cdf0e10cSrcweir +/-HUGE_VAL, underflow 0. In both cases pStatus is set to 296*cdf0e10cSrcweir rtl_math_ConversionStatus_OutOfRange, otherwise to 297*cdf0e10cSrcweir rtl_math_ConversionStatus_Ok. "INF", "-INF" and "+/-1.#INF" are 298*cdf0e10cSrcweir recognized as +/-HUGE_VAL, pStatus is set to 299*cdf0e10cSrcweir rtl_math_ConversionStatus_OutOfRange. "NaN" and "+/-1.#NAN" are 300*cdf0e10cSrcweir recognized and the value is set to +/-NAN, pStatus is set to 301*cdf0e10cSrcweir rtl_math_ConversionStatus_Ok. 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir @param pBegin 304*cdf0e10cSrcweir Points to the start of the byte string to convert. Must not be null. 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir @param pEnd 307*cdf0e10cSrcweir Points one past the end of the byte string to convert. The condition 308*cdf0e10cSrcweir pEnd >= pBegin must hold. 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir @param cDecSeparator 311*cdf0e10cSrcweir The decimal separator. 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir @param cGroupSeparator 314*cdf0e10cSrcweir The group (aka thousands) separator. 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir @param pStatus 317*cdf0e10cSrcweir If non-null, returns the status of the conversion. 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir @param pParsedEnd 320*cdf0e10cSrcweir If non-null, returns one past the position of the last character parsed 321*cdf0e10cSrcweir away. Thus if [pBegin..pEnd) only contains the numerical string to be 322*cdf0e10cSrcweir parsed, *pParsedEnd == pEnd on return. If no numerical (sub-)string is 323*cdf0e10cSrcweir found, *pParsedEnd == pBegin on return, even if there was leading 324*cdf0e10cSrcweir whitespace. 325*cdf0e10cSrcweir */ 326*cdf0e10cSrcweir double SAL_CALL rtl_math_stringToDouble( 327*cdf0e10cSrcweir sal_Char const * pBegin, sal_Char const * pEnd, sal_Char cDecSeparator, 328*cdf0e10cSrcweir sal_Char cGroupSeparator, enum rtl_math_ConversionStatus * pStatus, 329*cdf0e10cSrcweir sal_Char const ** pParsedEnd) SAL_THROW_EXTERN_C(); 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir /** Conversion analogous to strtod(), convert a string representing a 332*cdf0e10cSrcweir decimal number into a double value. 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir Leading tabs (U+0009) and spaces (U+0020) are eaten. Overflow returns 335*cdf0e10cSrcweir +/-HUGE_VAL, underflow 0. In both cases pStatus is set to 336*cdf0e10cSrcweir rtl_math_ConversionStatus_OutOfRange, otherwise to 337*cdf0e10cSrcweir rtl_math_ConversionStatus_Ok. "INF", "-INF" and "+/-1.#INF" are 338*cdf0e10cSrcweir recognized as +/-HUGE_VAL, pStatus is set to 339*cdf0e10cSrcweir rtl_math_ConversionStatus_OutOfRange. "NaN" and "+/-1.#NAN" are 340*cdf0e10cSrcweir recognized and the value is set to +/-NAN, pStatus is set to 341*cdf0e10cSrcweir rtl_math_ConversionStatus_Ok. 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir @param pBegin 344*cdf0e10cSrcweir Points to the start of the Unicode string to convert. Must not be null. 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir @param pEnd 347*cdf0e10cSrcweir Points one past the end of the Unicode string to convert. The condition 348*cdf0e10cSrcweir pEnd >= pBegin must hold. 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir @param cDecSeparator 351*cdf0e10cSrcweir The decimal separator. 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir @param cGroupSeparator 354*cdf0e10cSrcweir The group (aka thousands) separator. 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir @param pStatus 357*cdf0e10cSrcweir If non-null, returns the status of the conversion. 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir @param pParsedEnd 360*cdf0e10cSrcweir If non-null, returns one past the position of the last character parsed 361*cdf0e10cSrcweir away. Thus if [pBegin..pEnd) only contains the numerical string to be 362*cdf0e10cSrcweir parsed, *pParsedEnd == pEnd on return. If no numerical (sub-)string is 363*cdf0e10cSrcweir found, *pParsedEnd == pBegin on return, even if there was leading 364*cdf0e10cSrcweir whitespace. 365*cdf0e10cSrcweir */ 366*cdf0e10cSrcweir double SAL_CALL rtl_math_uStringToDouble( 367*cdf0e10cSrcweir sal_Unicode const * pBegin, sal_Unicode const * pEnd, 368*cdf0e10cSrcweir sal_Unicode cDecSeparator, sal_Unicode cGroupSeparator, 369*cdf0e10cSrcweir enum rtl_math_ConversionStatus * pStatus, sal_Unicode const ** pParsedEnd) 370*cdf0e10cSrcweir SAL_THROW_EXTERN_C(); 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir /** Rounds a double value. 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir @param fValue 375*cdf0e10cSrcweir Specifies the value to be rounded. 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir @param nDecPlaces 378*cdf0e10cSrcweir Specifies the decimal place where rounding occurs. Must be in the range 379*cdf0e10cSrcweir -20 to +20, inclusive. Negative if rounding occurs before the decimal 380*cdf0e10cSrcweir point. 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir @param eMode 383*cdf0e10cSrcweir Specifies the rounding mode. 384*cdf0e10cSrcweir */ 385*cdf0e10cSrcweir double SAL_CALL rtl_math_round(double fValue, int nDecPlaces, 386*cdf0e10cSrcweir enum rtl_math_RoundingMode eMode) 387*cdf0e10cSrcweir SAL_THROW_EXTERN_C(); 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir /** Scales fVal to a power of 10 without calling pow() or div() for nExp values 390*cdf0e10cSrcweir between -16 and +16, providing a faster method. 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir @param fValue 393*cdf0e10cSrcweir The value to be raised. 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir @param nExp 396*cdf0e10cSrcweir The exponent. 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir @return 399*cdf0e10cSrcweir fVal * pow(10.0, nExp) 400*cdf0e10cSrcweir */ 401*cdf0e10cSrcweir double SAL_CALL rtl_math_pow10Exp(double fValue, int nExp) SAL_THROW_EXTERN_C(); 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir /** Rounds value to 15 significant decimal digits. 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir @param fValue 406*cdf0e10cSrcweir The value to be rounded. 407*cdf0e10cSrcweir */ 408*cdf0e10cSrcweir double SAL_CALL rtl_math_approxValue(double fValue) SAL_THROW_EXTERN_C(); 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir /** Returns more accurate e^x-1 for x near 0 than calculating directly. 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir expm1 is part of the C99 standard, but not provided by some compilers. 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir @param fValue 415*cdf0e10cSrcweir The value x in the term e^x-1. 416*cdf0e10cSrcweir */ 417*cdf0e10cSrcweir double SAL_CALL rtl_math_expm1(double fValue) SAL_THROW_EXTERN_C(); 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir /** Returns more accurate log(1+x) for x near 0 than calculating directly. 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir log1p is part of the C99 standard, but not provided by some compilers. 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir @param fValue 424*cdf0e10cSrcweir The value x in the term log(1+x). 425*cdf0e10cSrcweir */ 426*cdf0e10cSrcweir double SAL_CALL rtl_math_log1p(double fValue) SAL_THROW_EXTERN_C(); 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir /** Returns more accurate atanh(x) for x near 0 than calculating 429*cdf0e10cSrcweir 0.5*log((1+x)/(1-x)). 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir atanh is part of the C99 standard, but not provided by some compilers. 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir @param fValue 434*cdf0e10cSrcweir The value x in the term atanh(x). 435*cdf0e10cSrcweir */ 436*cdf0e10cSrcweir double SAL_CALL rtl_math_atanh(double fValue) SAL_THROW_EXTERN_C(); 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir /** Returns values of the Errorfunction erf. 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir erf is part of the C99 standard, but not provided by some compilers. 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir @param fValue 443*cdf0e10cSrcweir The value x in the term erf(x). 444*cdf0e10cSrcweir */ 445*cdf0e10cSrcweir double SAL_CALL rtl_math_erf(double fValue) SAL_THROW_EXTERN_C(); 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir /** Returns values of the complement Errorfunction erfc. 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir erfc is part of the C99 standard, but not provided by some compilers. 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir @param fValue 452*cdf0e10cSrcweir The value x in the term erfc(x). 453*cdf0e10cSrcweir */ 454*cdf0e10cSrcweir double SAL_CALL rtl_math_erfc(double fValue) SAL_THROW_EXTERN_C(); 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir /** Returns values of the inverse hyperbolic sine. 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir asinh is part of the C99 standard, but not provided by some compilers. 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir @param fValue 461*cdf0e10cSrcweir The value x in the term asinh(x). 462*cdf0e10cSrcweir */ 463*cdf0e10cSrcweir double SAL_CALL rtl_math_asinh(double fValue) SAL_THROW_EXTERN_C(); 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir /** Returns values of the inverse hyperbolic cosine. 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir acosh is part of the C99 standard, but not provided by some compilers. 468*cdf0e10cSrcweir 469*cdf0e10cSrcweir @param fValue 470*cdf0e10cSrcweir The value x in the term acosh(x). 471*cdf0e10cSrcweir */ 472*cdf0e10cSrcweir double SAL_CALL rtl_math_acosh(double fValue) SAL_THROW_EXTERN_C(); 473*cdf0e10cSrcweir 474*cdf0e10cSrcweir #if defined __cplusplus 475*cdf0e10cSrcweir } 476*cdf0e10cSrcweir #endif /* __cplusplus */ 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir #endif /* INCLUDED_RTL_MATH_H */ 479