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