LibreOffice: rtl/math.h Source File

LibreOffice LibreOffice 26.2 SDK C/C++ API Reference

Loading...
Searching...
No Matches
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/*
21 * This file is part of LibreOffice published API.
22 */
23
24#ifndef INCLUDED_RTL_MATH_H
25#define INCLUDED_RTL_MATH_H
26
27#include "sal/config.h"
28
29#include "rtl/ustring.h"
30#include "sal/saldllapi.h"
31#include "sal/types.h"
32
33#if defined __cplusplus
34extern "C" {
35#endif /* __cplusplus */
36
40 enum rtl_math_StringFormat
41{
44 rtl_math_StringFormat_E,
45
48 rtl_math_StringFormat_F,
49
53 rtl_math_StringFormat_G,
54
58 rtl_math_StringFormat_Automatic,
59
63 rtl_math_StringFormat_E1,
64
68 rtl_math_StringFormat_E2,
69
73 rtl_math_StringFormat_G1,
74
78 rtl_math_StringFormat_G2,
79
81 rtl_math_StringFormat_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
83};
84
87 enum rtl_math_ConversionStatus
88{
91 rtl_math_ConversionStatus_Ok,
92
95 rtl_math_ConversionStatus_OutOfRange,
96
98 rtl_math_ConversionStatus_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
100};
101
104 enum rtl_math_RoundingMode
105{
108 rtl_math_RoundingMode_Corrected,
109
112 rtl_math_RoundingMode_Down,
113
116 rtl_math_RoundingMode_Up,
117
120 rtl_math_RoundingMode_Floor,
121
124 rtl_math_RoundingMode_Ceiling,
125
128 rtl_math_RoundingMode_HalfDown,
129
132 rtl_math_RoundingMode_HalfUp,
133
136 rtl_math_RoundingMode_HalfEven,
137
139 rtl_math_RoundingMode_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
141};
142
146 enum rtl_math_DecimalPlaces
147{
150 rtl_math_DecimalPlaces_Max = 0x7ffffff,
151
156 rtl_math_DecimalPlaces_DefaultSignificance = rtl_math_DecimalPlaces_Max
157};
158
159
224 SAL_DLLPUBLIC void SAL_CALL rtl_math_doubleToString(rtl_String ** pResult,
225 sal_Int32 * pResultCapacity,
226 sal_Int32 nResultOffset, double fValue,
227 enum rtl_math_StringFormat eFormat,
228 sal_Int32 nDecPlaces,
229 char cDecSeparator,
230 sal_Int32 const * pGroups,
231 char cGroupSeparator,
232 sal_Bool bEraseTrailingDecZeros)
233 SAL_THROW_EXTERN_C();
234
299 SAL_DLLPUBLIC void SAL_CALL rtl_math_doubleToUString(rtl_uString ** pResult,
300 sal_Int32 * pResultCapacity,
301 sal_Int32 nResultOffset, double fValue,
302 enum rtl_math_StringFormat eFormat,
303 sal_Int32 nDecPlaces,
304 sal_Unicode cDecSeparator,
305 sal_Int32 const * pGroups,
306 sal_Unicode cGroupSeparator,
307 sal_Bool bEraseTrailingDecZeros)
308 SAL_THROW_EXTERN_C();
309
345 SAL_DLLPUBLIC double SAL_CALL rtl_math_stringToDouble(
346 char const * pBegin, char const * pEnd, char cDecSeparator,
347 char cGroupSeparator, enum rtl_math_ConversionStatus * pStatus,
348 char const ** pParsedEnd) SAL_THROW_EXTERN_C();
349
385 SAL_DLLPUBLIC double SAL_CALL rtl_math_uStringToDouble(
386 sal_Unicode const * pBegin, sal_Unicode const * pEnd,
387 sal_Unicode cDecSeparator, sal_Unicode cGroupSeparator,
388 enum rtl_math_ConversionStatus * pStatus, sal_Unicode const ** pParsedEnd)
389 SAL_THROW_EXTERN_C();
390
404 SAL_DLLPUBLIC double SAL_CALL rtl_math_round(double fValue, int nDecPlaces,
405 enum rtl_math_RoundingMode eMode)
406 SAL_THROW_EXTERN_C();
407
420 SAL_DLLPUBLIC double SAL_CALL rtl_math_pow10Exp(double fValue, int nExp) SAL_THROW_EXTERN_C();
421
427 SAL_DLLPUBLIC double SAL_CALL rtl_math_approxValue(double fValue) SAL_THROW_EXTERN_C();
428
437 SAL_DLLPUBLIC bool SAL_CALL rtl_math_approxEqual(double a, double b) SAL_THROW_EXTERN_C();
438
446 SAL_DLLPUBLIC double SAL_CALL rtl_math_expm1(double fValue) SAL_THROW_EXTERN_C();
447
455 SAL_DLLPUBLIC double SAL_CALL rtl_math_log1p(double fValue) SAL_THROW_EXTERN_C();
456
465 SAL_DLLPUBLIC double SAL_CALL rtl_math_atanh(double fValue) SAL_THROW_EXTERN_C();
466
474 SAL_DLLPUBLIC double SAL_CALL rtl_math_erf(double fValue) SAL_THROW_EXTERN_C();
475
483 SAL_DLLPUBLIC double SAL_CALL rtl_math_erfc(double fValue) SAL_THROW_EXTERN_C();
484
492 SAL_DLLPUBLIC double SAL_CALL rtl_math_asinh(double fValue) SAL_THROW_EXTERN_C();
493
501 SAL_DLLPUBLIC double SAL_CALL rtl_math_acosh(double fValue) SAL_THROW_EXTERN_C();
502
503#if defined __cplusplus
504}
505#endif /* __cplusplus */
506
507#endif /* INCLUDED_RTL_MATH_H */
508
509/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
saldllapi.h
SAL_DLLPUBLIC
#define SAL_DLLPUBLIC
Definition saldllapi.h:34
types.h
SAL_MAX_ENUM
#define SAL_MAX_ENUM
Definition types.h:205
sal_Bool
unsigned char sal_Bool
Definition types.h:38
SAL_THROW_EXTERN_C
#define SAL_THROW_EXTERN_C()
Nothrow specification for C functions.
Definition types.h:352
sal_Unicode
sal_uInt16 sal_Unicode
Definition types.h:123
config.h
rtl_math_erf
SAL_DLLPUBLIC double rtl_math_erf(double fValue) SAL_THROW_EXTERN_C()
Returns values of the Errorfunction erf.
rtl_math_RoundingMode
rtl_math_RoundingMode
Rounding modes for rtl_math_round.
Definition math.h:105
rtl_math_RoundingMode_Ceiling
@ rtl_math_RoundingMode_Ceiling
Ceil of signed value.
Definition math.h:124
rtl_math_RoundingMode_Down
@ rtl_math_RoundingMode_Down
Floor of absolute value, signed return (commercial).
Definition math.h:112
rtl_math_RoundingMode_Up
@ rtl_math_RoundingMode_Up
Ceil of absolute value, signed return (commercial).
Definition math.h:116
rtl_math_RoundingMode_Corrected
@ rtl_math_RoundingMode_Corrected
Like HalfUp, but corrects roundoff errors, preferred.
Definition math.h:108
rtl_math_RoundingMode_HalfDown
@ rtl_math_RoundingMode_HalfDown
Frac <= 0.5 ?
Definition math.h:128
rtl_math_RoundingMode_HalfUp
@ rtl_math_RoundingMode_HalfUp
Frac < 0.5 ?
Definition math.h:132
rtl_math_RoundingMode_HalfEven
@ rtl_math_RoundingMode_HalfEven
IEEE rounding mode (statistical).
Definition math.h:136
rtl_math_RoundingMode_Floor
@ rtl_math_RoundingMode_Floor
Floor of signed value.
Definition math.h:120
rtl_math_ConversionStatus
rtl_math_ConversionStatus
Status for rtl_math_stringToDouble and rtl_math_uStringToDouble.
Definition math.h:88
rtl_math_ConversionStatus_Ok
@ rtl_math_ConversionStatus_Ok
Conversion was successful.
Definition math.h:91
rtl_math_ConversionStatus_OutOfRange
@ rtl_math_ConversionStatus_OutOfRange
Conversion caused overflow or underflow.
Definition math.h:95
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_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_DecimalPlaces
rtl_math_DecimalPlaces
Special decimal places constants for rtl_math_doubleToString and rtl_math_doubleToUString and rtl_mat...
Definition math.h:147
rtl_math_DecimalPlaces_DefaultSignificance
@ rtl_math_DecimalPlaces_DefaultSignificance
Value to be used with rtl_math_StringFormat_G.
Definition math.h:156
rtl_math_DecimalPlaces_Max
@ rtl_math_DecimalPlaces_Max
Value to be used with rtl_math_StringFormat_Automatic.
Definition math.h:150
rtl_math_StringFormat
rtl_math_StringFormat
Formatting modes for rtl_math_doubleToString and rtl_math_doubleToUString and rtl_math_doubleToUStrin...
Definition math.h:41
rtl_math_StringFormat_E
@ rtl_math_StringFormat_E
Like sprintf() E.
Definition math.h:44
rtl_math_StringFormat_E2
@ rtl_math_StringFormat_E2
Same 'E', but with only 2 minimum digits in exponent.
Definition math.h:68
rtl_math_StringFormat_Automatic
@ rtl_math_StringFormat_Automatic
Automatic, 'F' or 'E' format is used depending on the numeric value to be formatted.
Definition math.h:58
rtl_math_StringFormat_G1
@ rtl_math_StringFormat_G1
Same 'G', but with only 1 minimum digits in exponent.
Definition math.h:73
rtl_math_StringFormat_E1
@ rtl_math_StringFormat_E1
Same 'E', but with only 1 minimum digits in exponent.
Definition math.h:63
rtl_math_StringFormat_G2
@ rtl_math_StringFormat_G2
Same 'G', but with only 2 minimum digits in exponent.
Definition math.h:78
rtl_math_StringFormat_G
@ rtl_math_StringFormat_G
Like sprintf() G, 'F' or 'E' format is used depending on which one is more compact.
Definition math.h:53
rtl_math_StringFormat_F
@ rtl_math_StringFormat_F
Like sprintf() f.
Definition math.h:48
rtl_math_asinh
SAL_DLLPUBLIC double rtl_math_asinh(double fValue) SAL_THROW_EXTERN_C()
Returns values of the inverse hyperbolic sine.
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, char cDecSeparator, sal_Int32 const *pGroups, char cGroupSeparator, sal_Bool bEraseTrailingDecZeros) SAL_THROW_EXTERN_C()
Conversions analogous to sprintf() using internal rounding.
rtl_math_erfc
SAL_DLLPUBLIC double rtl_math_erfc(double fValue) SAL_THROW_EXTERN_C()
Returns values of the complement Errorfunction erfc.
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_approxValue
SAL_DLLPUBLIC double rtl_math_approxValue(double fValue) SAL_THROW_EXTERN_C()
Rounds value to 15 significant decimal digits.
rtl_math_approxEqual
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 ...
rtl_math_stringToDouble
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.
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,...
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_acosh
SAL_DLLPUBLIC double rtl_math_acosh(double fValue) SAL_THROW_EXTERN_C()
Returns values of the inverse hyperbolic cosine.
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_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.
ustring.h