xtd 0.2.0
math.h
Go to the documentation of this file.
1 #pragma once
4 #include "static.h"
5 #include "types.h"
6 #include <limits>
7 
9 namespace xtd {
20  class math static_ {
21  public:
23 
27  static constexpr double e = 2.7182818284590452354;
31  [[deprecated("Replaced by xtd::double_object::epsilon - Will be removed in version 0.4.0")]]
32  static constexpr double epsilon = 4.94066e-324;
36  [[deprecated("Replaced by xtd::double_object::positive_infinity - Will be removed in version 0.4.0")]]
37  static constexpr double infinity = std::numeric_limits<double>::infinity();
41  [[deprecated("Replaced by xtd::double_object::max_value - Will be removed in version 0.4.0")]]
42  static constexpr double max_value = std::numeric_limits<double>::max();
46  [[deprecated("Replaced by xtd::double_object::min_value - Will be removed in version 0.4.0")]]
47  static constexpr double min_value = std::numeric_limits<double>::lowest();
51  [[deprecated("Replaced by xtd::double_object::NaN - Will be removed in version 0.4.0")]]
52  static constexpr double NaN = std::numeric_limits<double>::quiet_NaN();
56  [[deprecated("Replaced by xtd::double_object::negative_infinity - Will be removed in version 0.4.0")]]
57  static constexpr double negative_infinity = -std::numeric_limits<double>::infinity();
60  static constexpr double pi = 3.14159265358979323846;
64  [[deprecated("Replaced by xtd::double_object::positive_infinity - Will be removed in version 0.4.0")]]
65  static constexpr double positive_infinity = +std::numeric_limits<double>::infinity();
68  static constexpr double tau = 2.7182818284590451;
70 
72 
77  static decimal abs(decimal value);
81  static double abs(double value);
85  static float abs(float value);
90  static int16 abs(int16 value);
95  static int32 abs(int32 value);
100  static int64 abs(int64 value);
105  static sbyte abs(sbyte value);
110  static slong abs(slong value);
111 
115  static double acos(double value);
116 
120  static double asin(double value);
121 
125  static double atan(double value);
126 
143  static double atan2(double y, double x);
144 
149  static int64 big_mul(int32 a, int32 b);
150 
154  static decimal ceiling(decimal value);
155 
159  static double ceiling(double value);
160 
166  static xtd::byte clamp(xtd::byte value, xtd::byte min, xtd::byte max) noexcept;
172  static decimal clamp(decimal value, decimal min, decimal max) noexcept;
178  static double clamp(double value, double min, double max) noexcept;
184  static int16 clamp(int16 value, int16 min, int16 max) noexcept;
190  static int32 clamp(int32 value, int32 min, int32 max) noexcept;
196  static int64 clamp(int64 value, int64 min, int64 max) noexcept;
202  static slong clamp(slong value, slong min, slong max) noexcept;
208  static sbyte clamp(sbyte value, sbyte min, sbyte max) noexcept;
214  static float clamp(float value, float min, float max) noexcept;
220  static uint16 clamp(uint16 value, uint16 min, uint16 max) noexcept;
226  static uint32 clamp(uint32 value, uint32 min, uint32 max) noexcept;
232  static uint64 clamp(uint64 value, uint64 min, uint64 max) noexcept;
238  static xtd::ulong clamp(xtd::ulong value, xtd::ulong min, xtd::ulong max) noexcept;
239 
243  static double cos(double value);
244 
248  static double cosh(double value);
249 
253  static double degrees_to_radians(double degrees) noexcept;
254 
260  static int32 div_rem(int32 dividend, int32 divisor, int32& remainder);
266  static int64 div_rem(int64 dividend, int64 divisor, int64& remainder);
267 
271  static double exp(double value);
272 
276  static decimal floor(decimal value);
280  static double floor(double value);
281 
288  static double ieee_remainder(double dividend, double divisor);
289 
294  [[deprecated("Replaced by xtd::double_object::is_infinity - Will be removed in version 0.4.0")]]
295  static bool is_infinity(double value) noexcept;
296 
301  [[deprecated("Replaced by xtd::double_object::is_negative_infinity - Will be removed in version 0.4.0")]]
302  static bool is_negative_infinity(double value) noexcept;
303 
308  [[deprecated("Replaced by xtd::double_object::is_positive_infinity - Will be removed in version 0.4.0")]]
309  static bool is_positive_infinity(double value) noexcept;
310 
315  [[deprecated("Replaced by xtd::double_object::is_NaN - Will be removed in version 0.4.0")]]
316  static bool is_NaN(double value) noexcept;
317 
330  static double log(double value);
331 
353  static double log(double a, double new_base);
354 
367  static double log10(double value);
368 
373  static xtd::byte max(xtd::byte a, xtd::byte b) noexcept;
378  static decimal max(decimal a, decimal b) noexcept;
383  static double max(double a, double b) noexcept;
388  static int16 max(int16 a, int16 b) noexcept;
393  static int32 max(int32 a, int32 b) noexcept;
398  static int64 max(int64 a, int64 b) noexcept;
403  static slong max(slong a, slong b) noexcept;
408  static sbyte max(sbyte a, sbyte b) noexcept;
413  static float max(float a, float b) noexcept;
418  static uint16 max(uint16 a, uint16 b) noexcept;
423  static uint32 max(uint32 a, uint32 b) noexcept;
428  static uint64 max(uint64 a, uint64 b) noexcept;
433  static xtd::ulong max(xtd::ulong a, xtd::ulong b) noexcept;
434 
439  static xtd::byte min(xtd::byte a, xtd::byte b) noexcept;
444  static decimal min(decimal a, decimal b) noexcept;
449  static double min(double a, double b) noexcept;
454  static int16 min(int16 a, int16 b) noexcept;
459  static int32 min(int32 a, int32 b) noexcept;
464  static int64 min(int64 a, int64 b) noexcept;
469  static slong min(slong a, slong b) noexcept;
474  static sbyte min(sbyte a, sbyte b) noexcept;
479  static float min(float a, float b) noexcept;
484  static uint16 min(uint16 a, uint16 b) noexcept;
489  static uint32 min(uint32 a, uint32 b) noexcept;
494  static uint64 min(uint64 a, uint64 b) noexcept;
499  static xtd::ulong min(xtd::ulong a, xtd::ulong b) noexcept;
500 
525  static double pow(double x, double y);
526 
530  static double radians_to_degrees(double radians) noexcept;
531 
535  static decimal round(decimal value);
540  static decimal round(decimal value, int32 decimals);
544  static double round(double value);
549  static double round(double value, int32 decimals);
550 
561  static int32 sign(decimal value);
572  static int32 sign(double value);
582  static int32 sign(int16 value);
592  static int32 sign(int32 value);
602  static int32 sign(int64 value);
612  static int32 sign(slong value);
622  static int32 sign(sbyte value);
633  static int32 sign(float value);
634 
638  static double sin(double value);
639 
643  static double sinh(double value);
644 
655  static double sqrt(double value);
656 
660  static double tan(double value);
661 
665  static double tanh(double value);
666 
676  static decimal truncate(decimal value);
686  static double truncate(double value);
688  };
689 }
static constexpr double NaN
Represents not a number (NaN). This field is constant.
Definition: math.h:52
Contains xtd::static_object class.
static decimal abs(decimal value)
Returns the absolute value of a decimal number.
Contains xtd fundamental types.
static constexpr double epsilon
Represents the smallest positive Double value greater than zero. This field is constant.
Definition: math.h:32
int_least8_t sbyte
Represents a 8-bit signed integer.
Definition: types.h:173
#define static_
This keyword is use to represent a static object. A static object can&#39;t be instantiated (constructors...
Definition: static.h:37
static double sin(double value)
Returns the sine of the specified angle.
long double decimal
Represents a decimal-precision floating-point number.
Definition: types.h:96
static bool is_infinity(double value) noexcept
Returns a value indicating whether the specified number evaluates to negative or positive infinity...
Provides constants and static methods for trigonometric, logarithmic, and other common mathematical f...
Definition: math.h:20
static decimal round(decimal value)
Rounds a double-precision floating-point value to the nearest integral value.
static double pow(double x, double y)
Returns a specified number raised to the specified power.
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
static double atan2(double y, double x)
Returns the angle whose tangent is the specified number.
uint_least16_t uint16
Represents a 16-bit unsigned integer.
Definition: types.h:228
static int64 big_mul(int32 a, int32 b)
Produces the full product of two 32-bit numbers.
static int32 div_rem(int32 dividend, int32 divisor, int32 &remainder)
Calculates the quotient of two 32-bit signed integers and also returns the remainder in an output par...
static double atan(double value)
Returns the angle whose tangent is the specified number.
static double acos(double value)
Returns the angle whose cosine is the specified number.
static constexpr double tau
Represents the number of radians in one turn, specified by the constant, τ.
Definition: math.h:68
static double cosh(double value)
Returns the hyperbolic cosine of the specified angle.
static double radians_to_degrees(double radians) noexcept
Convert radians to degrees.
static double sinh(double value)
Returns the hyperbolic sine of the specified angle.
static double tanh(double value)
Returns the hyperbolic tangent of the specified angle.
static double ieee_remainder(double dividend, double divisor)
Returns the remainder resulting from the division of a specified number by another specified number...
static constexpr double pi
Represents the ratio of the circumference of a circle to its diameter, specified by the constant...
Definition: math.h:60
static constexpr double max_value
Represents the largest possible value of double. This field is constant.
Definition: math.h:42
static double degrees_to_radians(double degrees) noexcept
Convert degrees to radians.
static decimal truncate(decimal value)
Calculates the integral part of a specified double-precision floating-point number.
static bool is_NaN(double value) noexcept
Returns a value indicating whether the specified number evaluates to not a number.
static double tan(double value)
Returns the tangent of the specified angle.
__slong__ slong
Represents a 32-bit or 64-bit signed integer.
Definition: types.h:206
static double log10(double value)
Returns the base 10 logarithm of a specified number.
static decimal ceiling(decimal value)
Returns the smallest integer greater than or equal to the specified double-precision floating-point n...
int_least16_t int16
Represents a 16-bit signed integer.
Definition: types.h:118
static decimal floor(decimal value)
Returns the largest integer less than or equal to the specified decimal number.
static constexpr double infinity
Represents infinity. This field is constant.
Definition: math.h:37
int_least32_t int32
Represents a 32-bit signed integer.
Definition: types.h:129
static double asin(double value)
Returns the angle whose sine is the specified number.
static constexpr double min_value
Represents the smallest possible value of double. This field is constant.
Definition: math.h:47
static bool is_negative_infinity(double value) noexcept
Returns a value indicating whether the specified number evaluates to negative infinity.
static double log(double value)
Returns the natural (base e) logarithm of a specified number.
__ulong__ ulong
Represents a 32-bit or 64-bit unsigned integer.
Definition: types.h:272
static double exp(double value)
Returns e raised to the specified power.
static constexpr double positive_infinity
Represents positive infinity. This field is constant.
Definition: math.h:65
static int32 sign(decimal value)
Returns a value indicating the sign of a double-precision floating-point number.
uint_least64_t uint64
Represents a 64-bit unsigned integer.
Definition: types.h:250
int_least64_t int64
Represents a 64-bit signed integer.
Definition: types.h:140
uint_least8_t byte
Represents a 8-bit unsigned integer.
Definition: types.h:39
static double sqrt(double value)
Returns the square root of a specified number.
uint_least32_t uint32
Represents a 32-bit unsigned integer.
Definition: types.h:239
static constexpr double e
Represents the natural logarithmic base, specified by the constant, e. This field is constant...
Definition: math.h:27
static xtd::byte clamp(xtd::byte value, xtd::byte min, xtd::byte max) noexcept
Returns value clamped to the inclusive range of min and max.
static constexpr double negative_infinity
Represents negative infinity. This field is constant.
Definition: math.h:57
static double cos(double value)
Returns the cosine of the specified angle.
static bool is_positive_infinity(double value) noexcept
Returns a value indicating whether the specified number evaluates to positive infinity.
static xtd::byte min(xtd::byte a, xtd::byte b) noexcept
Returns the smaller of two 8-bit unsigned integers.
static xtd::byte max(xtd::byte a, xtd::byte b) noexcept
Returns the larger of two 8-bit unsigned integers.