LibreOffice LibreOffice 4.3 SDK C/C++ API Reference

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
math.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20 #ifndef INCLUDED_RTL_MATH_H
21 #define INCLUDED_RTL_MATH_H
22
23 #include <sal/config.h>
24
25 #include <rtl/ustring.h>
26 #include <sal/saldllapi.h>
27 #include <sal/types.h>
28
29 #if defined __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
32
36 enum rtl_math_StringFormat
37 {
40 rtl_math_StringFormat_E,
41
44 rtl_math_StringFormat_F,
45
49 rtl_math_StringFormat_G,
50
54 rtl_math_StringFormat_Automatic,
55
57 rtl_math_StringFormat_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
59 };
60
63 enum rtl_math_ConversionStatus
64 {
67 rtl_math_ConversionStatus_Ok,
68
71 rtl_math_ConversionStatus_OutOfRange,
72
74 rtl_math_ConversionStatus_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
76 };
77
80 enum rtl_math_RoundingMode
81 {
84 rtl_math_RoundingMode_Corrected,
85
88 rtl_math_RoundingMode_Down,
89
92 rtl_math_RoundingMode_Up,
93
96 rtl_math_RoundingMode_Floor,
97
100 rtl_math_RoundingMode_Ceiling,
101
104 rtl_math_RoundingMode_HalfDown,
105
108 rtl_math_RoundingMode_HalfUp,
109
112 rtl_math_RoundingMode_HalfEven,
113
115 rtl_math_RoundingMode_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
117 };
118
122 enum rtl_math_DecimalPlaces
123 {
126 rtl_math_DecimalPlaces_Max = 0x7ffffff,
127
132 rtl_math_DecimalPlaces_DefaultSignificance = rtl_math_DecimalPlaces_Max
133 };
134
135
200 SAL_DLLPUBLIC void SAL_CALL rtl_math_doubleToString(rtl_String ** pResult,
201 sal_Int32 * pResultCapacity,
202 sal_Int32 nResultOffset, double fValue,
203 enum rtl_math_StringFormat eFormat,
204 sal_Int32 nDecPlaces,
205 sal_Char cDecSeparator,
206 sal_Int32 const * pGroups,
207 sal_Char cGroupSeparator,
208 sal_Bool bEraseTrailingDecZeros)
209 SAL_THROW_EXTERN_C();
210
275 SAL_DLLPUBLIC void SAL_CALL rtl_math_doubleToUString(rtl_uString ** pResult,
276 sal_Int32 * pResultCapacity,
277 sal_Int32 nResultOffset, double fValue,
278 enum rtl_math_StringFormat eFormat,
279 sal_Int32 nDecPlaces,
280 sal_Unicode cDecSeparator,
281 sal_Int32 const * pGroups,
282 sal_Unicode cGroupSeparator,
283 sal_Bool bEraseTrailingDecZeros)
284 SAL_THROW_EXTERN_C();
285
321 SAL_DLLPUBLIC double SAL_CALL rtl_math_stringToDouble(
322 sal_Char const * pBegin, sal_Char const * pEnd, sal_Char cDecSeparator,
323 sal_Char cGroupSeparator, enum rtl_math_ConversionStatus * pStatus,
324 sal_Char const ** pParsedEnd) SAL_THROW_EXTERN_C();
325
361 SAL_DLLPUBLIC double SAL_CALL rtl_math_uStringToDouble(
362 sal_Unicode const * pBegin, sal_Unicode const * pEnd,
363 sal_Unicode cDecSeparator, sal_Unicode cGroupSeparator,
364 enum rtl_math_ConversionStatus * pStatus, sal_Unicode const ** pParsedEnd)
365 SAL_THROW_EXTERN_C();
366
380 SAL_DLLPUBLIC double SAL_CALL rtl_math_round(double fValue, int nDecPlaces,
381 enum rtl_math_RoundingMode eMode)
382 SAL_THROW_EXTERN_C();
383
396 SAL_DLLPUBLIC double SAL_CALL rtl_math_pow10Exp(double fValue, int nExp) SAL_THROW_EXTERN_C();
397
403 SAL_DLLPUBLIC double SAL_CALL rtl_math_approxValue(double fValue) SAL_THROW_EXTERN_C();
404
412 SAL_DLLPUBLIC double SAL_CALL rtl_math_expm1(double fValue) SAL_THROW_EXTERN_C();
413
421 SAL_DLLPUBLIC double SAL_CALL rtl_math_log1p(double fValue) SAL_THROW_EXTERN_C();
422
431 SAL_DLLPUBLIC double SAL_CALL rtl_math_atanh(double fValue) SAL_THROW_EXTERN_C();
432
440 SAL_DLLPUBLIC double SAL_CALL rtl_math_erf(double fValue) SAL_THROW_EXTERN_C();
441
449 SAL_DLLPUBLIC double SAL_CALL rtl_math_erfc(double fValue) SAL_THROW_EXTERN_C();
450
458 SAL_DLLPUBLIC double SAL_CALL rtl_math_asinh(double fValue) SAL_THROW_EXTERN_C();
459
467 SAL_DLLPUBLIC double SAL_CALL rtl_math_acosh(double fValue) SAL_THROW_EXTERN_C();
468
469 #if defined __cplusplus
470 }
471 #endif /* __cplusplus */
472
473 #endif /* INCLUDED_RTL_MATH_H */
474
475 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl_math_doubleToUString
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_expm1
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.
rtl_math_RoundingMode_Up
Ceil of absolute value, signed return (commercial).
Definition: math.h:92
types.h
ustring.h
sal_Bool
unsigned char sal_Bool
Definition: types.h:46
rtl_math_ConversionStatus_OutOfRange
Conversion caused overflow or underflow.
Definition: math.h:71
rtl_math_erf
SAL_DLLPUBLIC double rtl_math_erf(double fValue) SAL_THROW_EXTERN_C()
Returns values of the Errorfunction erf.
rtl_math_StringFormat_E
Like sprintf() E.
Definition: math.h:40
rtl_math_log1p
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.
rtl_math_atanh
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)).
rtl_math_RoundingMode_HalfUp
Frac < 0.5 ? floor of abs : ceil of abs, signed return (mathematical).
Definition: math.h:108
rtl_math_RoundingMode_HalfDown
Frac <= 0.5 ? floor of abs : ceil of abs, signed return.
Definition: math.h:104
rtl_math_RoundingMode_Ceiling
Ceil of signed value.
Definition: math.h:100
rtl_math_approxValue
SAL_DLLPUBLIC double rtl_math_approxValue(double fValue) SAL_THROW_EXTERN_C()
Rounds value to 15 significant decimal digits.
rtl_math_StringFormat_F
Like sprintf() f.
Definition: math.h:44
rtl_math_pow10Exp
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...
sal_Char
char sal_Char
A legacy synonym for char.
Definition: types.h:128
rtl_math_DecimalPlaces
rtl_math_DecimalPlaces
Special decimal places constants for rtl_math_doubleToString and rtl_math_doubleToUString and rtl_mat...
Definition: math.h:122
saldllapi.h
rtl_math_StringFormat_G
Like sprintf() G, 'F' or 'E' format is used depending on which one is more compact.
Definition: math.h:49
rtl_math_RoundingMode_Floor
Floor of signed value.
Definition: math.h:96
rtl_math_acosh
SAL_DLLPUBLIC double rtl_math_acosh(double fValue) SAL_THROW_EXTERN_C()
Returns values of the inverse hyperbolic cosine.
rtl_math_stringToDouble
SAL_DLLPUBLIC double rtl_math_stringToDouble(sal_Char const *pBegin, sal_Char const *pEnd, sal_Char cDecSeparator, sal_Char cGroupSeparator, enum rtl_math_ConversionStatus *pStatus, sal_Char const **pParsedEnd) SAL_THROW_EXTERN_C()
Conversion analogous to strtod(), convert a string representing a decimal number into a double value...
rtl_math_RoundingMode_Down
Floor of absolute value, signed return (commercial).
Definition: math.h:88
rtl_math_doubleToString
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, sal_Char cDecSeparator, sal_Int32 const *pGroups, sal_Char cGroupSeparator, sal_Bool bEraseTrailingDecZeros) SAL_THROW_EXTERN_C()
Conversions analogous to sprintf() using internal rounding.
rtl_math_round
SAL_DLLPUBLIC double rtl_math_round(double fValue, int nDecPlaces, enum rtl_math_RoundingMode eMode) SAL_THROW_EXTERN_C()
Rounds a double value.
rtl_math_StringFormat
rtl_math_StringFormat
Formatting modes for rtl_math_doubleToString and rtl_math_doubleToUString and rtl_math_doubleToUStrin...
Definition: math.h:36
SAL_DLLPUBLIC
#define SAL_DLLPUBLIC
Definition: saldllapi.h:30
rtl_math_DecimalPlaces_DefaultSignificance
Value to be used with rtl_math_StringFormat_G.
Definition: math.h:132
rtl_math_ConversionStatus
rtl_math_ConversionStatus
Status for rtl_math_stringToDouble and rtl_math_uStringToDouble.
Definition: math.h:63
rtl_math_uStringToDouble
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...
config.h
SAL_THROW_EXTERN_C
#define SAL_THROW_EXTERN_C()
Nothrow specification for C functions.
Definition: types.h:367
rtl_math_erfc
SAL_DLLPUBLIC double rtl_math_erfc(double fValue) SAL_THROW_EXTERN_C()
Returns values of the complement Errorfunction erfc.
rtl_math_DecimalPlaces_Max
Value to be used with rtl_math_StringFormat_Automatic.
Definition: math.h:126
rtl_math_RoundingMode
rtl_math_RoundingMode
Rounding modes for rtl_math_round.
Definition: math.h:80
sal_Unicode
sal_uInt16 sal_Unicode
Definition: types.h:150
rtl_math_StringFormat_Automatic
Automatic, 'F' or 'E' format is used depending on the numeric value to be formatted.
Definition: math.h:54
rtl_math_asinh
SAL_DLLPUBLIC double rtl_math_asinh(double fValue) SAL_THROW_EXTERN_C()
Returns values of the inverse hyperbolic sine.
rtl_math_RoundingMode_HalfEven
IEEE rounding mode (statistical).
Definition: math.h:112
rtl_math_RoundingMode_Corrected
Like HalfUp, but corrects roundoff errors, preferred.
Definition: math.h:84
rtl_math_ConversionStatus_Ok
Conversion was successful.
Definition: math.h:67