3#ifndef _aspose_system_math_h_
4#define _aspose_system_math_h_
6#include <system/primitive_types.h>
7#include <system/decimal.h>
48 static const double ASPOSECPP_SHARED_API
PI;
50 static const double ASPOSECPP_SHARED_API
E;
55 static ASPOSECPP_SHARED_API
double Acos(
double d);
59 static ASPOSECPP_SHARED_API
double Asin(
double d);
63 static ASPOSECPP_SHARED_API
double Atan(
double d);
68 static ASPOSECPP_SHARED_API
double Atan2(
double y,
double x);
76 static ASPOSECPP_SHARED_API
double Ceiling(
double a);
80 static ASPOSECPP_SHARED_API
double Cos(
double d);
84 static ASPOSECPP_SHARED_API
double Cosh(
double value);
92 static ASPOSECPP_SHARED_API
double Floor(
double d);
96 static ASPOSECPP_SHARED_API
double Sin(
double a);
100 static ASPOSECPP_SHARED_API
double Tan(
double a);
104 static ASPOSECPP_SHARED_API
double Sinh(
double value);
108 static ASPOSECPP_SHARED_API
double Tanh(
double value);
112 static ASPOSECPP_SHARED_API
double Round(
double a);
117 static ASPOSECPP_SHARED_API
double Round(
double value,
int digits);
164 static ASPOSECPP_SHARED_API
double Truncate(
double d);
168 static ASPOSECPP_SHARED_API
double Sqrt(
double d);
172 static ASPOSECPP_SHARED_API
double Log(
double d);
176 static ASPOSECPP_SHARED_API
double Log10(
double d);
180 static ASPOSECPP_SHARED_API
double Exp(
double d);
185 static ASPOSECPP_SHARED_API
double Pow(
double x,
double y);
198 static_assert(std::is_arithmetic<T>::value,
"Math::Abs template argument must be an arithmetic type.");
200 return std::abs(value);
207 return d < 0 ? -d : d;
214 static ASPOSECPP_SHARED_API
double Log(
double a,
double newBase);
221 static typename std::enable_if<std::is_integral<T>::value && !std::is_unsigned<T>::value,
int>::type
Sign(T value)
236 static typename std::enable_if<std::is_floating_point<T>::value,
int>::type
Sign(T value)
245 throw ArithmeticException(u
"NaN");
260 static ASPOSECPP_SHARED_API int64_t
BigMul(
int a,
int b);
267 static ASPOSECPP_SHARED_API
int DivRem(
int a,
int b,
int &result);
273 static ASPOSECPP_SHARED_API int64_t
DivRem(int64_t a, int64_t b, int64_t &result);
284 static const double ASPOSECPP_SHARED_API
NaN;
294 return std::fmod(x,y);
303 template<class T0, class T1, class = typename std::enable_if<!std::is_same<T0, T1>::value,
void>::type>
304 static auto Min(T0 val1, T1 val2) ->
decltype(val1 + val2)
306 return Min_<decltype(val1 + val2)>(val1, val2);
314 template<class T0, class T1, class = typename std::enable_if<std::is_same<T0, T1>::value,
void>::type>
315 static T0
Min(T0 val1, T1 val2)
317 return Min_<decltype(val1 + val2)>(val1, val2);
326 template<class T0, class T1, class = typename std::enable_if<!std::is_same<T0, T1>::value,
void>::type>
327 static auto Max(T0 val1, T1 val2) ->
decltype(val1 + val2)
329 using T =
decltype(val1 + val2);
330 return Max_<T>(
static_cast<T
>(val1),
static_cast<T
>(val2));
338 template<class T0, class T1, class = typename std::enable_if<std::is_same<T0, T1>::value,
void>::type>
339 static T0
Max(T0 val1, T1 val2)
341 return Max_<T0>(val1,
static_cast<T0
>(val2));
351 static T Min_(T val1, T val2)
353 return val1 <= val2 ? val1 : val2;
362 static T Max_(T val1, T val2)
364 return val1 >= val2 ? val1 : val2;
368 enum { MaxRoundingDigits = 15 };
370 static const double RoundPower10Double[];
371 static const double DoubleRoundLimit;
379 static ASPOSECPP_SHARED_API
double RoundImpl(
double value,
int digits,
MidpointRounding mode);
387 inline float Math::Min_(
float val1,
float val2)
391 if (System::IsNaN<float>(val1))
401 inline double Math::Min_(
double val1,
double val2)
405 if (System::IsNaN<double>(val1))
415 inline float Math::Max_(
float val1,
float val2)
419 if (System::IsNaN<float>(val1))
429 inline double Math::Max_(
double val1,
double val2)
433 if (System::IsNaN<double>(val1))
Represents a decimal number. This type should be allocated on stack and passed to functions by value ...
Definition: decimal.h:107
int CompareTo(const Decimal &d) const
Determines if the value represented by the current object is less than, equal to or greater than the ...
static const Decimal Zero
Represents number 0.
Definition: decimal.h:123
Definition: db_command.h:9
MidpointRounding
Specifies the behavior of rounding functions.
Definition: midpoint_rounding.h:10
Contains math functions. This is a static type with no instance services. You should never create ins...
Definition: math.h:46
static T Modulus(T x, T y)
Calculates the remainder resulting from the division one specified value by another specified value.
Definition: math.h:292
static std::enable_if< std::is_integral< T >::value &&!std::is_unsigned< T >::value, int >::type Sign(T value)
Determines the sign of the specified signed integral value.
Definition: math.h:221
static const double PI
The number Pi constant.
Definition: math.h:48
static double Round(double value, int digits)
Rounds the specified value to the nearest value with the specified number of fractional digits.
static T0 Min(T0 val1, T1 val2)
Returns the smallest value out of two numeric ones specified.
Definition: math.h:315
static double Acos(double d)
Calculates the arccosine of the specified value.
static auto Min(T0 val1, T1 val2) -> decltype(val1+val2)
Returns the smallest value out of two numeric ones specified.
Definition: math.h:304
static double Pow(double x, double y)
Returns the specified value raised to the specified power.
static double Atan2(double y, double x)
Calculates the arctan of the ration of the specified values.
static double Sinh(double value)
Calculates the hyperbolic sine of the specified value.
static Decimal Round(const Decimal &value, int digits)
Rounds the specified value to the nearest value with the specified number of fractional digits.
static double Log10(double d)
Returns the base-10 logarithm of the specified value.
static T0 Max(T0 val1, T1 val2)
Returns the greatest value out of two numeric ones specified.
Definition: math.h:339
static T Abs(T value)
Returns the absolute value of the specified value.
Definition: math.h:196
static double Tan(double a)
Calculates the tangen of the specified value.
static Decimal Round(const Decimal &d, MidpointRounding mode)
Rounds the specified value to the nearest integral number. A parameter specifies the function's behav...
static double Floor(double d)
Returns the largest integral value that is less than or equal to the specified value.
static Decimal Round(const Decimal &d, int digits, MidpointRounding mode)
Rounds the specified value to the nearest value with the specified number of fractional digits....
static auto Max(T0 val1, T1 val2) -> decltype(val1+val2)
Returns the greatest value out of two numeric ones specified.
Definition: math.h:327
static double IEEERemainder(double x, double y)
Returns the remainder resulting from the division of a specified number by another specified number.
static Decimal Round(const Decimal &d)
Rounds the specified value to the nearest integral value.
static int64_t BigMul(int a, int b)
Returns the full product of two 32-bit integers.
static double Sin(double a)
Calculates the sine of the specified value.
static Decimal Floor(const Decimal &d)
Returns the largest integral value that is less than or equal to the specified value.
static std::enable_if< std::is_floating_point< T >::value, int >::type Sign(T value)
Determines the sign of the specified floating-point value.
Definition: math.h:236
static double Log(double a, double newBase)
Returns the logarithm of the specified value in the specified base.
static double Tanh(double value)
Calculates the hyperbolic tangen of the specified value.
static double Round(double value, MidpointRounding mode)
Rounds the specified value to the nearest integral number. A parameter specifies the function's behav...
static double Exp(double d)
Returns e constant raised to the specified power.
static Decimal Abs(const Decimal &d)
Returns the absolute value of a value represented by the specified Decimal object.
Definition: math.h:205
static double Sqrt(double d)
Returns the square root of the specified value.
static const double NegativeInfinity
Represents the negative infinity.
Definition: math.h:282
static double Atan(double d)
Calculates the arctan of the specified value.
static double Ceiling(double a)
Returns the smallest integral value that is greater than or equal to the specified value.
static const double NaN
Represents a not-a-number value.
Definition: math.h:284
static int64_t DivRem(int64_t a, int64_t b, int64_t &result)
Calculates the quotient of two 64-bit integers and the remainder.
static const double E
Natural logarithm's base.
Definition: math.h:50
static int Sign(const Decimal &value)
Determines the sign of the specified decimal value.
Definition: math.h:251
static double Truncate(double d)
Returns a double-precision floating point value that has integral part equal to that of the specified...
static double Round(double value, int digits, MidpointRounding mode)
Rounds the specified value to the nearest value with the specified number of fractional digits....
static double Round(double a)
Rounds the specified value to the nearest integral value.
static const double PositiveInfinity
Represents the positive infinity.
Definition: math.h:280
static Decimal Truncate(const Decimal &d)
Returns the Decimal object representing a value that has integral part equal to that of the value rep...
static double Cos(double d)
Calculates the cosine of the specified value.
static double Asin(double d)
Calculates the arcsin of the specified value.
static double Cosh(double value)
Calculates the hyperbolic cosine of the specified value.
static double Log(double d)
Returns the natural logarithm of the specified value.
static Decimal Ceiling(const Decimal &d)
Returns the smallest integral value that is greater than or equal to the specified value.
static int DivRem(int a, int b, int &result)
Calculates the quotient of two 32-bit integers and the remainder.