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;
30  static constexpr double epsilon = 4.94066e-324;
33  static constexpr double infinity = std::numeric_limits<double>::infinity();
36  static constexpr double max_value = std::numeric_limits<double>::max();
39  static constexpr double min_value = std::numeric_limits<double>::lowest();
42  static constexpr double NaN = std::numeric_limits<double>::quiet_NaN();
45  static constexpr double negative_infinity = -infinity;
48  static constexpr double pi = 3.14159265358979323846;
51  static constexpr double positive_infinity = +infinity;
54  static constexpr double tau = 2.7182818284590451;
56 
58 
63  static decimal abs(decimal value);
67  static double abs(double value);
71  static float abs(float value);
76  static int16 abs(int16 value);
81  static int32 abs(int32 value);
86  static int64 abs(int64 value);
91  static sbyte abs(sbyte value);
96  static slong abs(slong value);
97 
101  static double acos(double value);
102 
106  static double asin(double value);
107 
111  static double atan(double value);
112 
129  static double atan2(double y, double x);
130 
135  static int64 big_mul(int32 a, int32 b);
136 
140  static decimal ceiling(decimal value);
141 
145  static double ceiling(double value);
146 
152  static xtd::byte clamp(xtd::byte value, xtd::byte min, xtd::byte max) noexcept;
158  static decimal clamp(decimal value, decimal min, decimal max) noexcept;
164  static double clamp(double value, double min, double max) noexcept;
170  static int16 clamp(int16 value, int16 min, int16 max) noexcept;
176  static int32 clamp(int32 value, int32 min, int32 max) noexcept;
182  static int64 clamp(int64 value, int64 min, int64 max) noexcept;
188  static slong clamp(slong value, slong min, slong max) noexcept;
194  static sbyte clamp(sbyte value, sbyte min, sbyte max) noexcept;
200  static float clamp(float value, float min, float max) noexcept;
206  static uint16 clamp(uint16 value, uint16 min, uint16 max) noexcept;
212  static uint32 clamp(uint32 value, uint32 min, uint32 max) noexcept;
218  static uint64 clamp(uint64 value, uint64 min, uint64 max) noexcept;
224  static xtd::ulong clamp(xtd::ulong value, xtd::ulong min, xtd::ulong max) noexcept;
225 
229  static double cos(double value);
230 
234  static double cosh(double value);
235 
239  static double degrees_to_radians(double degrees) noexcept;
240 
246  static int32 div_rem(int32 dividend, int32 divisor, int32& remainder);
252  static int64 div_rem(int64 dividend, int64 divisor, int64& remainder);
253 
257  static double exp(double value);
258 
262  static decimal floor(decimal value);
266  static double floor(double value);
267 
274  static double ieee_remainder(double dividend, double divisor);
275 
279  static bool is_infinity(double value) noexcept;
280 
284  static bool is_negative_infinity(double value) noexcept;
285 
289  static bool is_positive_infinity(double value) noexcept;
290 
294  static bool is_NaN(double value) noexcept;
295 
308  static double log(double value);
309 
331  static double log(double a, double new_base);
332 
345  static double log10(double value);
346 
351  static xtd::byte max(xtd::byte a, xtd::byte b) noexcept;
356  static decimal max(decimal a, decimal b) noexcept;
361  static double max(double a, double b) noexcept;
366  static int16 max(int16 a, int16 b) noexcept;
371  static int32 max(int32 a, int32 b) noexcept;
376  static int64 max(int64 a, int64 b) noexcept;
381  static slong max(slong a, slong b) noexcept;
386  static sbyte max(sbyte a, sbyte b) noexcept;
391  static float max(float a, float b) noexcept;
396  static uint16 max(uint16 a, uint16 b) noexcept;
401  static uint32 max(uint32 a, uint32 b) noexcept;
406  static uint64 max(uint64 a, uint64 b) noexcept;
411  static xtd::ulong max(xtd::ulong a, xtd::ulong b) noexcept;
412 
417  static xtd::byte min(xtd::byte a, xtd::byte b) noexcept;
422  static decimal min(decimal a, decimal b) noexcept;
427  static double min(double a, double b) noexcept;
432  static int16 min(int16 a, int16 b) noexcept;
437  static int32 min(int32 a, int32 b) noexcept;
442  static int64 min(int64 a, int64 b) noexcept;
447  static slong min(slong a, slong b) noexcept;
452  static sbyte min(sbyte a, sbyte b) noexcept;
457  static float min(float a, float b) noexcept;
462  static uint16 min(uint16 a, uint16 b) noexcept;
467  static uint32 min(uint32 a, uint32 b) noexcept;
472  static uint64 min(uint64 a, uint64 b) noexcept;
477  static xtd::ulong min(xtd::ulong a, xtd::ulong b) noexcept;
478 
503  static double pow(double x, double y);
504 
508  static double radians_to_degrees(double radians) noexcept;
509 
513  static decimal round(decimal value);
518  static decimal round(decimal value, int32 decimals);
522  static double round(double value);
527  static double round(double value, int32 decimals);
528 
539  static int32 sign(decimal value);
550  static int32 sign(double value);
560  static int32 sign(int16 value);
570  static int32 sign(int32 value);
580  static int32 sign(int64 value);
590  static int32 sign(slong value);
600  static int32 sign(sbyte value);
611  static int32 sign(float value);
612 
616  static double sin(double value);
617 
621  static double sinh(double value);
622 
633  static double sqrt(double value);
634 
638  static double tan(double value);
639 
643  static double tanh(double value);
644 
654  static decimal truncate(decimal value);
664  static double truncate(double value);
666  };
667 }
static constexpr double NaN
Represents not a number (NaN). This field is constant.
Definition: math.h:42
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:30
int_least8_t sbyte
Represents a 8-bit signed integer.
Definition: types.h:112
#define static_
This keyword is use to represent a static object. A static object can&#39;t be instantiated (constructors...
Definition: static.h:38
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:58
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:144
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:54
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:48
static constexpr double max_value
Represents the largest possible value of double. This field is constant.
Definition: math.h:36
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:128
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:66
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:33
int_least32_t int32
Represents a 32-bit signed integer.
Definition: types.h:74
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:39
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:176
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:51
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:160
int_least64_t int64
Represents a 64-bit signed integer.
Definition: types.h:82
uint_least8_t byte
Represents a 8-bit unsigned integer.
Definition: types.h:26
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:152
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:45
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.