CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
mathf.h
1
3#ifndef _aspose_system_mathf_h_
4#define _aspose_system_mathf_h_
5
6#include <system/primitive_types.h>
7#include <system/midpoint_rounding.h>
8#include <type_traits>
9
10namespace System
11{
15struct MathF
16{
18 static const float ASPOSECPP_SHARED_API PI; // 2.71828183
20 static const float ASPOSECPP_SHARED_API E; // 3.14159265f
22 static const float ASPOSECPP_SHARED_API Tau; // 6.283185307
23
27 static ASPOSECPP_SHARED_API float Acos(float x);
31 static ASPOSECPP_SHARED_API float Asin(float x);
35 static ASPOSECPP_SHARED_API float Atan(float x);
40 static ASPOSECPP_SHARED_API float Atan2(float y, float x);
44 static ASPOSECPP_SHARED_API float Ceiling(float a);
48 static ASPOSECPP_SHARED_API float Cos(float x);
52 static ASPOSECPP_SHARED_API float Cosh(float value);
56 static ASPOSECPP_SHARED_API float Floor(float x);
60 static ASPOSECPP_SHARED_API float Sin(float a);
64 static ASPOSECPP_SHARED_API float Tan(float a);
68 static ASPOSECPP_SHARED_API float Sinh(float value);
72 static ASPOSECPP_SHARED_API float Tanh(float value);
76 static ASPOSECPP_SHARED_API float Round(float a);
81 static ASPOSECPP_SHARED_API float Round(float value, int digits);
87 static ASPOSECPP_SHARED_API float Round(float value, MidpointRounding mode);
94 static ASPOSECPP_SHARED_API float Round(float value, int digits, MidpointRounding mode);
100 static ASPOSECPP_SHARED_API float Truncate(float x);
104 static ASPOSECPP_SHARED_API float Sqrt(float x);
108 static ASPOSECPP_SHARED_API float Log(float x);
112 static ASPOSECPP_SHARED_API float Log10(float x);
116 static ASPOSECPP_SHARED_API float Exp(float x);
121 static ASPOSECPP_SHARED_API float Pow(float x, float y);
126 static ASPOSECPP_SHARED_API float IEEERemainder(float x, float y);
131 template<class T>
132 static T Abs(T value)
133 {
134 static_assert(std::is_arithmetic<T>::value, "Math::Abs template argument must be an arithmetic type.");
135
136 return std::abs(value);
137 }
138
143 static ASPOSECPP_SHARED_API float Log(float a, float newBase);
144
149 template<typename T>
150 static typename std::enable_if<std::is_integral<T>::value && !std::is_unsigned<T>::value, int>::type Sign(T value)
151 {
152 if (value == 0)
153 return 0;
154 else if (value > 0)
155 return 1;
156 else
157 return -1;
158 }
159
164 template<typename T>
165 static typename std::enable_if<std::is_floating_point<T>::value, int>::type Sign(T value)
166 {
167 if (value < 0)
168 return -1;
169 else if (value > 0)
170 return 1;
171 else if (value == 0)
172 return 0;
173
174 throw ArithmeticException(u"NaN");
175 }
176
178 enum { MaxRoundingDigits = 6 };
179
180
187 static ASPOSECPP_SHARED_API float RoundImpl(float value, int digits, MidpointRounding mode);
188};
189
190} // namespace System
191
192#endif // _mathf_h_
Definition: db_command.h:9
MidpointRounding
Specifies the behavior of rounding functions.
Definition: midpoint_rounding.h:10
Contains math functions for single-precision floating-point values. This is a static type with no ins...
Definition: mathf.h:16
static float Truncate(float x)
Returns a float-precision floating point value that has integral part equal to that of the specified ...
static float Floor(float x)
Returns the largest integral value that is less than or equal to the specified value.
static float Round(float a)
Rounds the specified value to the nearest integral value.
static float Sqrt(float x)
Returns the square root of the specified value.
static const float Tau
Tau value.
Definition: mathf.h:22
static float RoundImpl(float value, int digits, MidpointRounding mode)
Rounds the specified value to the nearest value with the specified number of fractional digits....
static float Pow(float x, float y)
Returns the specified value raised to the specified power.
static float Log(float x)
Returns the natural logarithm of the specified value.
static float IEEERemainder(float x, float y)
Returns the remainder resulting from the division of a specified number by another specified number.
static float Round(float value, MidpointRounding mode)
Rounds the specified value to the nearest integral number. A parameter specifies the function's behav...
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: mathf.h:150
static float Cos(float x)
Calculates the cosine of 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: mathf.h:165
static float Sinh(float value)
Calculates the hyperbolic sine of the specified value.
@ MaxRoundingDigits
Definition: mathf.h:178
static float Atan2(float y, float x)
Calculates the arctan of the ration of the specified values.
static float Ceiling(float a)
Returns the smallest integral value that is greater than or equal to the specified value.
static float Log10(float x)
Returns the base-10 logarithm of the specified value.
static const float E
Natural logarithm's base.
Definition: mathf.h:20
static float Tanh(float value)
Calculates the hyperbolic tangen of the specified value.
static float Cosh(float value)
Calculates the hyperbolic cosine of the specified value.
static float Asin(float x)
Calculates the arcsin of the specified value.
static float Atan(float x)
Calculates the arctan of the specified value.
static float Acos(float x)
Calculates the arccosine of the specified value.
static float Round(float value, int digits)
Rounds the specified value to the nearest value with the specified number of fractional digits.
static float Exp(float x)
Returns e constant raised to the specified power.
static float Round(float value, int digits, MidpointRounding mode)
Rounds the specified value to the nearest value with the specified number of fractional digits....
static const float PI
The number Pi constant.
Definition: mathf.h:18
static float Log(float a, float newBase)
Returns the logarithm of the specified value in the specified base.
static float Sin(float a)
Calculates the sine of the specified value.
static float Tan(float a)
Calculates the tangen of the specified value.
static T Abs(T value)
Returns the absolute value of the specified value.
Definition: mathf.h:132