xtd 0.2.0
Loading...
Searching...
No Matches
math.h
Go to the documentation of this file.
1
3#pragma once
4
6// Workaround : Like Windows.h (with NOMINMAX defined), some includes define max as a macro and this causes compilation errors.
7#if defined(_MSC_VER) && defined(max)
8# if __cplusplus < 202302L
9# pragma message("The macro `max` is defined. If you include the `Windows.h` file, please define the 'NOMINMAX' constant before including `Windows.h`. xtd will undef the `max` macro.")
10# else
11# warning "The macro `max` is defined. If you include the `Windows.h` file, please define the 'NOMINMAX' constant before including `Windows.h`. xtd will undef the `max` macro."
12# endif
13# undef max
14#endif
15#if defined(_MSC_VER) && defined(min)
16# if __cplusplus < 202302L
17# pragma message("The macro `min` is defined. If you include the `Windows.h` file, please define the 'NOMINMAX' constant before including `Windows.h`. xtd will undef the `min` macro.")
18# else
19# warning "The macro `min` is defined. If you include the `Windows.h` file, please define the 'NOMINMAX' constant before including `Windows.h`. xtd will undef the `min` macro."
20# endif
21# undef min
22#endif
24
25#include "double_object.h"
26#include "static.h"
27#include "types.h"
28#include <limits>
29
31namespace xtd {
42 class math static_ {
43 public:
45
49 static constexpr double e = 2.7182818284590452354;
53 [[deprecated("Replaced by xtd::double_object::epsilon - Will be removed in version 0.4.0")]]
54 static constexpr double epsilon = xtd::double_object::epsilon;
58 [[deprecated("Replaced by xtd::double_object::positive_infinity - Will be removed in version 0.4.0")]]
63 [[deprecated("Replaced by xtd::double_object::max_value - Will be removed in version 0.4.0")]]
64 static constexpr double max_value = xtd::double_object::max_value;
68 [[deprecated("Replaced by xtd::double_object::min_value - Will be removed in version 0.4.0")]]
69 static constexpr double min_value = xtd::double_object::min_value;
73 [[deprecated("Replaced by xtd::double_object::NaN - Will be removed in version 0.4.0")]]
74 static constexpr double NaN = xtd::double_object::NaN;
78 [[deprecated("Replaced by xtd::double_object::negative_infinity - Will be removed in version 0.4.0")]]
82 static constexpr double pi = 3.14159265358979323846;
86 [[deprecated("Replaced by xtd::double_object::positive_infinity - Will be removed in version 0.4.0")]]
90 static constexpr double tau = 2.7182818284590451;
92
94
99 static decimal abs(decimal value);
103 static double abs(double value);
107 static float abs(float value);
112 static int16 abs(int16 value);
117 static int32 abs(int32 value);
122 static int64 abs(int64 value);
127 static sbyte abs(sbyte value);
132 static slong abs(slong value);
133
137 static double acos(double value);
138
142 static double asin(double value);
143
147 static double atan(double value);
148
165 static double atan2(double y, double x);
166
172
176 static decimal ceiling(decimal value);
177
181 static double ceiling(double value);
182
194 static decimal clamp(decimal value, decimal min, decimal max) noexcept;
200 static double clamp(double value, double min, double max) noexcept;
206 static int16 clamp(int16 value, int16 min, int16 max) noexcept;
212 static int32 clamp(int32 value, int32 min, int32 max) noexcept;
218 static int64 clamp(int64 value, int64 min, int64 max) noexcept;
224 static slong clamp(slong value, slong min, slong max) noexcept;
230 static sbyte clamp(sbyte value, sbyte min, sbyte max) noexcept;
236 static float clamp(float value, float min, float max) noexcept;
242 static uint16 clamp(uint16 value, uint16 min, uint16 max) noexcept;
248 static uint32 clamp(uint32 value, uint32 min, uint32 max) noexcept;
254 static uint64 clamp(uint64 value, uint64 min, uint64 max) noexcept;
261
265 static double cos(double value);
266
270 static double cosh(double value);
271
275 static double degrees_to_radians(double degrees) noexcept;
276
282 static int32 div_rem(int32 dividend, int32 divisor, int32& remainder);
288 static int64 div_rem(int64 dividend, int64 divisor, int64& remainder);
289
293 static double exp(double value);
294
298 static decimal floor(decimal value);
302 static double floor(double value);
303
310 static double ieee_remainder(double dividend, double divisor);
311
316 [[deprecated("Replaced by xtd::double_object::is_infinity - Will be removed in version 0.4.0")]]
317 static bool is_infinity(double value) noexcept;
318
323 [[deprecated("Replaced by xtd::double_object::is_negative_infinity - Will be removed in version 0.4.0")]]
324 static bool is_negative_infinity(double value) noexcept;
325
330 [[deprecated("Replaced by xtd::double_object::is_positive_infinity - Will be removed in version 0.4.0")]]
331 static bool is_positive_infinity(double value) noexcept;
332
337 [[deprecated("Replaced by xtd::double_object::is_NaN - Will be removed in version 0.4.0")]]
338 static bool is_NaN(double value) noexcept;
339
352 static double log(double value);
353
375 static double log(double a, double new_base);
376
389 static double log10(double value);
390
395 static xtd::byte max(xtd::byte a, xtd::byte b) noexcept;
400 static decimal max(decimal a, decimal b) noexcept;
405 static double max(double a, double b) noexcept;
410 static int16 max(int16 a, int16 b) noexcept;
415 static int32 max(int32 a, int32 b) noexcept;
420 static int64 max(int64 a, int64 b) noexcept;
425 static slong max(slong a, slong b) noexcept;
430 static sbyte max(sbyte a, sbyte b) noexcept;
435 static float max(float a, float b) noexcept;
440 static uint16 max(uint16 a, uint16 b) noexcept;
445 static uint32 max(uint32 a, uint32 b) noexcept;
450 static uint64 max(uint64 a, uint64 b) noexcept;
456
461 static xtd::byte min(xtd::byte a, xtd::byte b) noexcept;
466 static decimal min(decimal a, decimal b) noexcept;
471 static double min(double a, double b) noexcept;
476 static int16 min(int16 a, int16 b) noexcept;
481 static int32 min(int32 a, int32 b) noexcept;
486 static int64 min(int64 a, int64 b) noexcept;
491 static slong min(slong a, slong b) noexcept;
496 static sbyte min(sbyte a, sbyte b) noexcept;
501 static float min(float a, float b) noexcept;
506 static uint16 min(uint16 a, uint16 b) noexcept;
511 static uint32 min(uint32 a, uint32 b) noexcept;
516 static uint64 min(uint64 a, uint64 b) noexcept;
522
547 static double pow(double x, double y);
548
552 static double radians_to_degrees(double radians) noexcept;
553
557 static decimal round(decimal value);
562 static decimal round(decimal value, int32 decimals);
566 static double round(double value);
571 static double round(double value, int32 decimals);
572
583 static int32 sign(decimal value);
594 static int32 sign(double value);
604 static int32 sign(int16 value);
614 static int32 sign(int32 value);
624 static int32 sign(int64 value);
634 static int32 sign(slong value);
644 static int32 sign(sbyte value);
655 static int32 sign(float value);
656
660 static double sin(double value);
661
665 static double sinh(double value);
666
677 static double sqrt(double value);
678
682 static double tan(double value);
683
687 static double tanh(double value);
688
698 static decimal truncate(decimal value);
708 static double truncate(double value);
710 };
711}
static constexpr type_t epsilon
Represents the smallest positive type_t value greater than zero. This field is constant.
Definition box_floating_point.h:54
static constexpr type_t NaN
Represents not a number (NaN). This field is constant.
Definition box_floating_point.h:57
static constexpr type_t positive_infinity
Represents positive infinity. This field is constant.
Definition box_floating_point.h:63
static constexpr type_t negative_infinity
Represents negative infinity. This field is constant.
Definition box_floating_point.h:60
static constexpr type_t max_value
Represents the largest possible value of type_t. This field is constant.
Definition box_integer.h:65
static constexpr type_t min_value
Represents the smallest possible value of type_t. This field is constant.
Definition box_integer.h:68
Provides constants and static methods for trigonometric, logarithmic, and other common mathematical f...
Definition math.h:42
static slong min(slong a, slong b) noexcept
Returns the smaller of two 64-bit signed integers.
static int32 clamp(int32 value, int32 min, int32 max) noexcept
Returns value clamped to the inclusive range of min and max.
static constexpr double min_value
Represents the smallest possible value of double. This field is constant.
Definition math.h:69
static double abs(double value)
Returns the absolute value of a double-precision floating-point number.
static double degrees_to_radians(double degrees) noexcept
Convert degrees to radians.
static double sqrt(double value)
Returns the square root of a specified number.
static int16 abs(int16 value)
Returns the absolute value of a 16-bit signed integer.
static uint64 min(uint64 a, uint64 b) noexcept
Returns the smaller of two 64-bit unsigned integers.
static constexpr double infinity
Represents infinity. This field is constant.
Definition math.h:59
static int32 sign(slong value)
Returns a value indicating the sign of a 64-bit signed integer.
static double floor(double value)
Returns the largest integer less than or equal to the specified decimal number.
static int32 sign(decimal value)
Returns a value indicating the sign of a double-precision floating-point number.
static double round(double value)
Rounds a double-precision floating-point value to the nearest integral value.
static int64 big_mul(int32 a, int32 b)
Produces the full product of two 32-bit numbers.
static constexpr double positive_infinity
Represents positive infinity. This field is constant.
Definition math.h:87
static uint16 min(uint16 a, uint16 b) noexcept
Returns the smaller of two 16-bit unsigned integers.
static decimal abs(decimal value)
Returns the absolute value of a decimal number.
static int16 clamp(int16 value, int16 min, int16 max) noexcept
Returns value clamped to the inclusive range of min and max.
static double atan2(double y, double x)
Returns the angle whose tangent is the specified number.
static int32 sign(sbyte value)
Returns a value indicating the sign of an 8-bit signed integer.
static xtd::byte min(xtd::byte a, xtd::byte b) noexcept
Returns the smaller of two 8-bit unsigned integers.
static uint64 clamp(uint64 value, uint64 min, uint64 max) noexcept
Returns value clamped to the inclusive range of min and max.
static double round(double value, int32 decimals)
Rounds a decimal value to a specified number of fractional digits.
static int32 max(int32 a, int32 b) noexcept
Returns the larger of two 32-bit signed integers.
static sbyte max(sbyte a, sbyte b) noexcept
Returns the larger of two 8-bit signed integers.
static constexpr double tau
Represents the number of radians in one turn, specified by the constant, τ.
Definition math.h:90
static constexpr double negative_infinity
Represents negative infinity. This field is constant.
Definition math.h:79
static int16 min(int16 a, int16 b) noexcept
Returns the smaller of two 16-bit signed integers.
static float clamp(float value, float min, float max) noexcept
Returns value clamped to the inclusive range of min and max.
static uint64 max(uint64 a, uint64 b) noexcept
Returns the larger of two 64-bit unsigned integers.
static decimal truncate(decimal value)
Calculates the integral part of a specified double-precision floating-point number.
static double exp(double value)
Returns e raised to the specified power.
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 uint16 max(uint16 a, uint16 b) noexcept
Returns the larger of two 16-bit unsigned integers.
static double min(double a, double b) noexcept
Returns the smaller of two double single.
static xtd::ulong max(xtd::ulong a, xtd::ulong b) noexcept
Returns the larger of two 64-bit unsigned integers.
static double log(double a, double new_base)
Returns the logarithm of a specified number in a specified base.
static constexpr double e
Represents the natural logarithmic base, specified by the constant, e. This field is constant.
Definition math.h:49
static xtd::ulong clamp(xtd::ulong value, xtd::ulong min, xtd::ulong max) noexcept
Returns value clamped to the inclusive range of min and max.
static uint32 min(uint32 a, uint32 b) noexcept
Returns the smaller of two 32-bit unsigned integers.
static double radians_to_degrees(double radians) noexcept
Convert radians to degrees.
static int16 max(int16 a, int16 b) noexcept
Returns the larger of two 16-bit signed integers.
static double tan(double value)
Returns the tangent of the specified angle.
static sbyte min(sbyte a, sbyte b) noexcept
Returns the smaller of two 8-bit signed integers.
static int64 min(int64 a, int64 b) noexcept
Returns the smaller of two 64-bit signed integers.
static int64 max(int64 a, int64 b) noexcept
Returns the larger of two 64-bit signed integers.
static double ieee_remainder(double dividend, double divisor)
Returns the remainder resulting from the division of a specified number by another specified number.
static int32 abs(int32 value)
Returns the absolute value of a 32-bit signed integer.
static bool is_infinity(double value) noexcept
Returns a value indicating whether the specified number evaluates to negative or positive infinity.
static decimal round(decimal value, int32 decimals)
Rounds a decimal value to a specified number of fractional digits.
static decimal clamp(decimal value, decimal min, decimal max) noexcept
Returns value clamped to the inclusive range of min and max.
static float abs(float value)
Returns the absolute value of a single-precision floating-point number.
static int32 sign(double value)
Returns a value indicating the sign of a double-precision floating-point number.
static double clamp(double value, double min, double max) noexcept
Returns value clamped to the inclusive range of min and max.
static double ceiling(double value)
Returns the smallest integer greater than or equal to the specified double-precision floating-point n...
static constexpr double epsilon
Represents the smallest positive Double value greater than zero. This field is constant.
Definition math.h:54
static int64 abs(int64 value)
Returns the absolute value of a 64-bit signed integer.
static double sin(double value)
Returns the sine of the specified angle.
static uint32 max(uint32 a, uint32 b) noexcept
Returns the larger of two 32-bit unsigned integers.
static double cos(double value)
Returns the cosine of the specified angle.
static decimal min(decimal a, decimal b) noexcept
Returns the smaller of two double single.
static int32 sign(float value)
Returns a value indicating the sign of a single-precision floating-point number.
static double pow(double x, double y)
Returns a specified number raised to the specified power.
static constexpr double NaN
Represents not a number (NaN). This field is constant.
Definition math.h:74
static sbyte abs(sbyte value)
Returns the absolute value of a 8-bit signed integer.
static uint32 clamp(uint32 value, uint32 min, uint32 max) noexcept
Returns value clamped to the inclusive range of min and max.
static double max(double a, double b) noexcept
Returns the larger of two double single.
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 sinh(double value)
Returns the hyperbolic sine of the specified angle.
static uint16 clamp(uint16 value, uint16 min, uint16 max) noexcept
Returns value clamped to the inclusive range of min and max.
static xtd::byte max(xtd::byte a, xtd::byte b) noexcept
Returns the larger of two 8-bit unsigned integers.
static sbyte clamp(sbyte value, sbyte min, sbyte max) noexcept
Returns value clamped to the inclusive range of min and max.
static double truncate(double value)
Calculates the integral part of a specified double-precision floating-point number.
static decimal round(decimal value)
Rounds a double-precision floating-point value to the nearest integral value.
static int32 min(int32 a, int32 b) noexcept
Returns the smaller of two 32-bit signed integers.
static constexpr double max_value
Represents the largest possible value of double. This field is constant.
Definition math.h:64
static decimal ceiling(decimal value)
Returns the smallest integer greater than or equal to the specified double-precision floating-point n...
static decimal floor(decimal value)
Returns the largest integer less than or equal to the specified decimal number.
static int32 sign(int16 value)
Returns a value indicating the sign of a 16-bit signed integer.
static float min(float a, float b) noexcept
Returns the smaller of two single single.
static int64 div_rem(int64 dividend, int64 divisor, int64 &remainder)
Calculates the quotient of two 64-bit signed integers and also returns the remainder in an output par...
static int32 sign(int32 value)
Returns a value indicating the sign of a 32-bit signed integer.
static slong clamp(slong value, slong min, slong max) noexcept
Returns value clamped to the inclusive range of min and max.
static float max(float a, float b) noexcept
Returns the larger of two single single.
static slong max(slong a, slong b) noexcept
Returns the larger of two 64-bit signed integers.
static double log10(double value)
Returns the base 10 logarithm of a specified number.
static double cosh(double value)
Returns the hyperbolic cosine of the specified angle.
static constexpr double pi
Represents the ratio of the circumference of a circle to its diameter, specified by the constant,...
Definition math.h:82
static double log(double value)
Returns the natural (base e) logarithm of a specified number.
static int32 sign(int64 value)
Returns a value indicating the sign of a 64-bit signed integer.
static double tanh(double value)
Returns the hyperbolic tangent 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 double atan(double value)
Returns the angle whose tangent is the specified number.
static decimal max(decimal a, decimal b) noexcept
Returns the larger of two double single.
static double acos(double value)
Returns the angle whose cosine is the specified number.
static double asin(double value)
Returns the angle whose sine is the specified number.
static slong abs(slong value)
Returns the absolute value of a 64-bit signed integer.
static int64 clamp(int64 value, int64 min, int64 max) noexcept
Returns value clamped to the inclusive range of min and max.
static bool is_NaN(double value) noexcept
Returns a value indicating whether the specified number evaluates to not a number.
static xtd::ulong min(xtd::ulong a, xtd::ulong b) noexcept
Returns the smaller of two 64-bit unsigned integers.
static bool is_negative_infinity(double value) noexcept
Returns a value indicating whether the specified number evaluates to negative infinity.
Contains xtd::double_object alias.
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.h:37
int_least16_t int16
Represents a 16-bit signed integer.
Definition types.h:120
long double decimal
Represents a decimal-precision floating-point number.
Definition types.h:98
__ulong__ ulong
Represents a 32-bit or 64-bit unsigned integer.
Definition types.h:274
int_least8_t sbyte
Represents a 8-bit signed integer.
Definition types.h:175
int_least64_t int64
Represents a 64-bit signed integer.
Definition types.h:142
uint_least16_t uint16
Represents a 16-bit unsigned integer.
Definition types.h:230
int_least32_t int32
Represents a 32-bit signed integer.
Definition types.h:131
uint_least64_t uint64
Represents a 64-bit unsigned integer.
Definition types.h:252
uint_least32_t uint32
Represents a 32-bit unsigned integer.
Definition types.h:241
__slong__ slong
Represents a 32-bit or 64-bit signed integer.
Definition types.h:208
uint_least8_t byte
Represents a 8-bit unsigned integer.
Definition types.h:41
@ a
The A key.
@ y
The Y key.
@ b
The B key.
@ x
The X key.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::static_object class.
Contains xtd fundamental types.