xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Static Public Attributes | Static Public Member Functions | List of all members
xtd::math Class Reference

#include <math.h>

Definition

Provides constants and static methods for trigonometric, logarithmic, and other common mathematical functions.

Namespace
xtd
Library
xtd.core
Remarks
This class cannot be inherited.
Examples
The following example uses several mathematical and trigonometric functions from the xtd::math class to calculate the inner angles of a trapezoid.
#include <xtd/xtd>
using namespace xtd;
namespace examples {
// The following class represents simple functionality of the trapezoid.
class math_trapezoid_sample : public object {
public:
// The main entry point for the application.
static void main() {
math_trapezoid_sample trpz(20.0, 10.0, 8.0, 6.0);
console::write_line("The trapezoid's bases are 20.0 and 10.0, the trapezoid's legs are 8.0 and 6.0");
double h = trpz.get_height();
console::write_line("trapezoid height is: {0}", h);
double dx_r = trpz.get_left_base_radian_angle();
console::write_line("trapezoid left base angle is: {0} Radians", dx_r);
double dy_r = trpz.get_right_base_radian_angle();
console::write_line("trapezoid right base angle is: {0} Radians", dy_r);
double dx_d = trpz.get_left_base_degree_angle();
console::write_line("trapezoid left base angle is: {0} Degrees", dx_d);
double dy_d = trpz.get_right_base_degree_angle();
console::write_line("trapezoid left base angle is: {0} Degrees", dy_d);
}
math_trapezoid_sample(double long_base, double short_base, double left_leg, double right_leg) {
long_base_ = math::abs(long_base);
short_base_ = math::abs(short_base);
left_leg_ = math::abs(left_leg);
right_leg_ = math::abs(right_leg);
}
double get_height() {
double x = get_right_small_base();
return math::sqrt(math::pow(right_leg_, 2.0) - math::pow(x, 2.0));
}
double get_square() {
return get_height() * long_base_ / 2.0;
}
double get_left_base_radian_angle() {
double sin_x = get_height() / left_leg_;
return math::round(math::asin(sin_x), 2);
}
double get_right_base_radian_angle() {
double x = get_right_small_base();
double cos_x = (math::pow(right_leg_, 2.0) + math::pow(x, 2.0) - math::pow(get_height(), 2.0)) / (2 * x * right_leg_);
return math::round(math::acos(cos_x), 2);
}
double get_left_base_degree_angle() {
double x = math::radians_to_degrees(get_left_base_radian_angle());
return math::round(x, 2);
}
double get_right_base_degree_angle() {
double x = math::radians_to_degrees(get_right_base_radian_angle());
return math::round(x, 2);
}
private:
double long_base_;
double short_base_;
double left_leg_;
double right_leg_;
double get_right_small_base() {
return (math::pow(right_leg_, 2.0) - math::pow(left_leg_, 2.0) + math::pow(long_base_, 2.0) + math::pow(short_base_, 2.0) - 2 * short_base_ * long_base_) / (2 * (long_base_ - short_base_));
}
};
}
startup_(examples::math_trapezoid_sample);
// This code produces the following output:
//
// The trapezoid's bases are 20.0 and 10.0, the trapezoid's legs are 8.0 and 6.0
// trapezoid height is: 4.8
// trapezoid left base angle is: 0.64 Radians
// trapezoid right base angle is: 0.93 Radians
// trapezoid left base angle is: 36.67 Degrees
// trapezoid left base angle is: 53.29 Degrees

Static Public Attributes

static constexpr double e = 2.7182818284590452354
 Represents the natural logarithmic base, specified by the constant, e. This field is constant. More...
 
static constexpr double epsilon = 4.94066e-324
 Represents the smallest positive Double value greater than zero. This field is constant. More...
 
static constexpr double infinity = std::numeric_limits<double>::infinity()
 Represents infinity. This field is constant. More...
 
static constexpr double max_value = std::numeric_limits<double>::max()
 Represents the largest possible value of double. This field is constant. More...
 
static constexpr double min_value = std::numeric_limits<double>::lowest()
 Represents the smallest possible value of double. This field is constant. More...
 
static constexpr double NaN = std::numeric_limits<double>::quiet_NaN()
 Represents not a number (NaN). This field is constant. More...
 
static constexpr double negative_infinity = -infinity
 Represents negative infinity. This field is constant. More...
 
static constexpr double pi = 3.14159265358979323846
 Represents the ratio of the circumference of a circle to its diameter, specified by the constant, π. This field is constant. More...
 
static constexpr double positive_infinity = +infinity
 Represents positive infinity. This field is constant. More...
 
static constexpr double tau = 2.7182818284590451
 Represents the number of radians in one turn, specified by the constant, τ. More...
 

Static Public Member Functions

static decimal_t abs (decimal_t value)
 Returns the absolute value of a decimal number. More...
 
static double abs (double value)
 Returns the absolute value of a double-precision floating-point number. More...
 
static float abs (float value)
 Returns the absolute value of a single-precision floating-point number. More...
 
static int16_t abs (int16_t value)
 Returns the absolute value of a 16-bit signed integer. More...
 
static int32_t abs (int32_t value)
 Returns the absolute value of a 32-bit signed integer. More...
 
static int64_t abs (int64_t value)
 Returns the absolute value of a 64-bit signed integer. More...
 
static sbyte_t abs (sbyte_t value)
 Returns the absolute value of a 8-bit signed integer. More...
 
static llong_t abs (llong_t value)
 Returns the absolute value of a 64-bit signed integer. More...
 
static double acos (double value)
 Returns the angle whose cosine is the specified number. More...
 
static double asin (double value)
 Returns the angle whose sine is the specified number. More...
 
static double atan (double value)
 Returns the angle whose tangent is the specified number. More...
 
static double atan2 (double y, double x)
 Returns the angle whose tangent is the specified number. More...
 
static int64_t big_mul (int32_t a, int32_t b)
 Produces the full product of two 32-bit numbers. More...
 
static decimal ceiling (decimal value)
 Returns the smallest integer greater than or equal to the specified double-precision floating-point number. More...
 
static double ceiling (double value)
 Returns the smallest integer greater than or equal to the specified double-precision floating-point number. More...
 
static double cos (double value)
 Returns the cosine of the specified angle. More...
 
static double cosh (double value)
 Returns the hyperbolic cosine of the specified angle. More...
 
static double degrees_to_radians (double degrees)
 Convert degrees to radians. More...
 
static int32_t div_rem (int32_t dividend, int32_t divisor, int32_t &remainder)
 Calculates the quotient of two 32-bit signed integers and also returns the remainder in an output parameter. More...
 
static int64_t div_rem (int64_t dividend, int64_t divisor, int64_t &remainder)
 Calculates the quotient of two 64-bit signed integers and also returns the remainder in an output parameter. More...
 
static double exp (double value)
 Returns e raised to the specified power. More...
 
static decimal_t floor (decimal_t value)
 Returns the largest integer less than or equal to the specified decimal number. More...
 
static double floor (double value)
 Returns the largest integer less than or equal to the specified decimal number. More...
 
static double ieee_remainder (double dividend, double divisor)
 Returns the remainder resulting from the division of a specified number by another specified number. More...
 
static bool is_infinity (double value)
 Returns a value indicating whether the specified number evaluates to negative or positive infinity. More...
 
static bool is_NaN (double value)
 Returns a value indicating whether the specified number evaluates to not a number. More...
 
static bool is_negative_infinity (double value)
 Returns a value indicating whether the specified number evaluates to negative infinity. More...
 
static bool is_positive_infinity (double value)
 Returns a value indicating whether the specified number evaluates to positive infinity. More...
 
static double log (double value)
 Returns the natural (base e) logarithm of a specified number. More...
 
static double log (double a, double new_base)
 Returns the logarithm of a specified number in a specified base. More...
 
static double log10 (double value)
 Returns the base 10 logarithm of a specified number. More...
 
static byte_t max (byte_t a, byte_t b)
 Returns the larger of two 8-bit unsigned integers. More...
 
static decimal_t max (decimal_t a, decimal_t b)
 Returns the larger of two double single. More...
 
static double max (double a, double b)
 Returns the larger of two double single. More...
 
static int16_t max (int16_t a, int16_t b)
 Returns the larger of two 16-bit signed integers. More...
 
static int32_t max (int32_t a, int32_t b)
 Returns the larger of two 32-bit signed integers. More...
 
static int64_t max (int64_t a, int64_t b)
 Returns the larger of two 64-bit signed integers. More...
 
static llong_t max (llong_t a, llong_t b)
 Returns the larger of two 64-bit signed integers. More...
 
static sbyte_t max (sbyte_t a, sbyte_t b)
 Returns the larger of two 8-bit signed integers. More...
 
static float max (float a, float b)
 Returns the larger of two single single. More...
 
static uint16_t max (uint16_t a, uint16_t b)
 Returns the larger of two 16-bit unsigned integers. More...
 
static uint32_t max (uint32_t a, uint32_t b)
 Returns the larger of two 32-bit unsigned integers. More...
 
static uint64_t max (uint64_t a, uint64_t b)
 Returns the larger of two 64-bit unsigned integers. More...
 
static ullong_t max (ullong_t a, ullong_t b)
 Returns the larger of two 64-bit unsigned integers. More...
 
static byte_t min (byte_t a, byte_t b)
 Returns the smaller of two 8-bit unsigned integers. More...
 
static decimal_t min (decimal_t a, decimal_t b)
 Returns the smaller of two double single. More...
 
static double min (double a, double b)
 Returns the smaller of two double single. More...
 
static int16_t min (int16_t a, int16_t b)
 Returns the smaller of two 16-bit signed integers. More...
 
static int32_t min (int32_t a, int32_t b)
 Returns the smaller of two 32-bit signed integers. More...
 
static int64_t min (int64_t a, int64_t b)
 Returns the smaller of two 64-bit signed integers. More...
 
static llong_t min (llong_t a, llong_t b)
 Returns the smaller of two 64-bit signed integers. More...
 
static sbyte_t min (sbyte_t a, sbyte_t b)
 Returns the smaller of two 8-bit signed integers. More...
 
static float min (float a, float b)
 Returns the smaller of two single single. More...
 
static uint16_t min (uint16_t a, uint16_t b)
 Returns the smaller of two 16-bit unsigned integers. More...
 
static uint32_t min (uint32 a, uint32 b)
 Returns the smaller of two 32-bit unsigned integers. More...
 
static uint64 min (uint64_t a, uint64_t b)
 Returns the smaller of two 64-bit unsigned integers. More...
 
static ullong_t min (ullong_t a, ullong_t b)
 Returns the smaller of two 64-bit unsigned integers. More...
 
static double pow (double x, double y)
 Returns a specified number raised to the specified power. More...
 
static double radians_to_degrees (double radians)
 Convert radians to degrees. More...
 
static decimal_t round (decimal_t value)
 Rounds a double-precision floating-point value to the nearest integral value. More...
 
static decimal_t round (decimal_t value, int32_t decimals)
 Rounds a decimal value to a specified number of fractional digits. More...
 
static double round (double value)
 Rounds a double-precision floating-point value to the nearest integral value. More...
 
static double round (double value, int32_t decimals)
 Rounds a decimal value to a specified number of fractional digits. More...
 
static int32_t sign (decimal_t value)
 Returns a value indicating the sign of a double-precision floating-point number. More...
 
static int32_t sign (double value)
 Returns a value indicating the sign of a double-precision floating-point number. More...
 
static int32_t sign (int16_t value)
 Returns a value indicating the sign of a 16-bit signed integer. More...
 
static int32_t sign (int32_t value)
 Returns a value indicating the sign of a 32-bit signed integer. More...
 
static int32_t sign (int64_t value)
 Returns a value indicating the sign of a 64-bit signed integer. More...
 
static int32_t sign (llong_t value)
 Returns a value indicating the sign of a 64-bit signed integer. More...
 
static int32_t sign (sbyte_t value)
 Returns a value indicating the sign of an 8-bit signed integer. More...
 
static int32_t sign (float value)
 Returns a value indicating the sign of a single-precision floating-point number. More...
 
static double sin (double value)
 Returns the sine of the specified angle. More...
 
static double sinh (double value)
 Returns the hyperbolic sine of the specified angle. More...
 
static double sqrt (double value)
 Returns the square root of a specified number. More...
 
static double tan (double value)
 Returns the tangent of the specified angle. More...
 
static double tanh (double value)
 Returns the hyperbolic tangent of the specified angle. More...
 
static decimal_t truncate (decimal_t value)
 Calculates the integral part of a specified double-precision floating-point number. More...
 
static double truncate (double value)
 Calculates the integral part of a specified double-precision floating-point number. More...
 

Member Function Documentation

◆ abs() [1/8]

static decimal_t xtd::math::abs ( decimal_t  value)
static

Returns the absolute value of a decimal number.

Parameters
valueA number in the range std::numeric_limit<decimal_t>::lowest() <= value <= std::numeric_limit<decimal_t>::max().
Returns
A decimal number, x, such that 0 <= x <= std::numeric_limit<decimal_t>::max()std::numeric_limit<decimal_t>::max().

◆ abs() [2/8]

static double xtd::math::abs ( double  value)
static

Returns the absolute value of a double-precision floating-point number.

Parameters
valueA number in the range std::numeric_limit<double>::lowest() <= value <= std::numeric_limit<double>::max().
Returns
A double-precision floating-point number, x, such that 0 <= x <= std::numeric_limit<douuble>::max().

◆ abs() [3/8]

static float xtd::math::abs ( float  value)
static

Returns the absolute value of a single-precision floating-point number.

Parameters
valueA number in the range std::numeric_limit<float>::lowest() <= value <= std::numeric_limit<float>::max().
Returns
A single-precision floating-point number, x, such that 0 <= x <= std::numeric_limit<float>::max().

◆ abs() [4/8]

static int16_t xtd::math::abs ( int16_t  value)
static

Returns the absolute value of a 16-bit signed integer.

Parameters
valueA number in the range std::numeric_limit<int16_t>::lowest() <= value <= std::numeric_limit<int16_t>::max().
Returns
A 16-bit signed integer, x, such that 0 <= x <= std::numeric_limit<int16_t>::max().
Exceptions
xtd::overflow_exceptionvalue equals std::numeric_limit<int16_t>::lowest().

◆ abs() [5/8]

static int32_t xtd::math::abs ( int32_t  value)
static

Returns the absolute value of a 32-bit signed integer.

Parameters
valueA number in the range std::numeric_limit<int32_t>::lowest() <= value <= std::numeric_limit<int32_t>::max().
Returns
A 32-bit signed integer, x, such that 0 <= x <= std::numeric_limit<int32_t>::max().
Exceptions
xtd::overflow_exceptionvalue equals std::numeric_limit<int32_t>::lowest().

◆ abs() [6/8]

static int64_t xtd::math::abs ( int64_t  value)
static

Returns the absolute value of a 64-bit signed integer.

Parameters
valueA number in the range std::numeric_limit<int64_t>::lowestlowest() <= value <= std::numeric_limit<int64_t>::max().
Returns
A 64-bit signed integer, x, such that 0 <= x <= std::numeric_limit<int64_t>::max().
Exceptions
xtd::overflow_exceptionvalue equals std::numeric_limit<int64_t>::lowest().

◆ abs() [7/8]

static sbyte_t xtd::math::abs ( sbyte_t  value)
static

Returns the absolute value of a 8-bit signed integer.

Parameters
valueA number in the range std::numeric_limit<sbyte_t>::lowest() <= value <= std::numeric_limit<sbyte_t>::max().
Returns
A 8-bit signed integer, x, such that 0 <= x <= std::numeric_limit<sbyte_t>::max().
Exceptions
xtd::overflow_exceptionvalue equals std::numeric_limit<sbyte_tsbyte_t>::lowest().

◆ abs() [8/8]

static llong_t xtd::math::abs ( llong_t  value)
static

Returns the absolute value of a 64-bit signed integer.

Parameters
valueA number in the range std::numeric_limit<llong_t>::lowest() <= value <= std::numeric_limit<llong_t>::max().
Returns
A 8-bit signed integer, x, such that 0 <= x <= std::numeric_limit<llong_t>::max().
Exceptions
xtd::overflow_exceptionvalue equals std::numeric_limit<llong_t>::lowest().

◆ acos()

static double xtd::math::acos ( double  value)
static

Returns the angle whose cosine is the specified number.

Parameters
valueA number representing a cosine, where -1 <= value <= 1.
Returns
An angle, A, measured in radians, such that 0 <= A <= PI. -or- math::NaN if value < -1 or d > 1.

◆ asin()

static double xtd::math::asin ( double  value)
static

Returns the angle whose sine is the specified number.

Parameters
valueA number representing a sine, where -1 <= value <= 1.
Returns
An angle, A, measured in radians, such that -PI/2 <= A <= PI/2. -or- math::NaN if value < -1 or d > 1.

◆ atan()

static double xtd::math::atan ( double  value)
static

Returns the angle whose tangent is the specified number.

Parameters
valueA number representing a tangent.
Returns
An angle, A, measured in radians, such that -PI/2 <= ? <= PI/2. -or- math::NaN if value equals math::NaN, -PI/2 rounded to double precision (-1.5707963267949) if d equals math::negative_infinity, or PI/2 rounded to double precision (1.5707963267949) if d equals math::positive_infinity

◆ atan2()

static double xtd::math::atan2 ( double  y,
double  x 
)
static

Returns the angle whose tangent is the specified number.

Parameters
yThe y coordinate of a point.
xThe x coordinate of a point.
Returns
An angle, A, measured in radians, such that -PI <= A <= PI, and tan(?) = y / x, where (x, y) is a point in the Cartesian plane. Observe the following:
  • For (x, y) in quadrant 1, 0 < A < PI/2.
  • For (x, y) in quadrant 2, PI/2 < A <= PI.
  • For (x, y) in quadrant 3, -PI < A < -PI/2.
  • For (x, y) in quadrant 4, -PI/2 < A < 0.
  • For points on the boundaries of the quadrants, the return value is the following:
  • If x is 0 and y is not negative, A = 0.
  • If x is 0 and y is negative, A = PI.
  • If x is positive and y is 0, A = PI/2.
  • If x is negative and y is 0, A = -PI/2.
Remarks
The return value is the angle in the Cartesian plane formed by the x-axis, and a vector starting from the origin, (0,0), and terminating at the point, (x,y).

◆ big_mul()

static int64_t xtd::math::big_mul ( int32_t  a,
int32_t  b 
)
static

Produces the full product of two 32-bit numbers.

Parameters
aThe first int32 to multiply.
bThe second int32 to multiply.
Returns
The int64 containing the product of the specified numbers.

◆ ceiling() [1/2]

static decimal xtd::math::ceiling ( decimal  value)
static

Returns the smallest integer greater than or equal to the specified double-precision floating-point number.

Parameters
valueA double-precision floating-point number.
Returns
The smallest integer greater than or equal to value. If value is equal to xtd::math::NaN, xtd::math::negative_infinity, or xtd::math::positive_infinity, that value is returned.

◆ ceiling() [2/2]

static double xtd::math::ceiling ( double  value)
static

Returns the smallest integer greater than or equal to the specified double-precision floating-point number.

Parameters
valueA double-precision floating-point number.
Returns
The smallest integer greater than or equal to value. If value is equal to xtd::math::NaN, xtd::math::negative_infinity, or xtd::math::positive_infinity, that value is returned.

◆ cos()

static double xtd::math::cos ( double  value)
static

Returns the cosine of the specified angle.

Parameters
valueAn angle, measured in radians.
Returns
The cosine of value. If value is equal to xtd::math::NaN, xtd::math::negative_infinity, or xtd::math::positive_infinity, this method returns xtd::math::NaN.

◆ cosh()

static double xtd::math::cosh ( double  value)
static

Returns the hyperbolic cosine of the specified angle.

Parameters
valueAn angle, measured in radians.
Returns
The hyperbolic cosine of value. If value is equal to xtd::math::negative_infinity() or xtd::math::posittive_:infinity, xtd::math::positive_infinity is returned. If value is equal to xtd::math::NaN, xtd::math::NaN is returned.

◆ degrees_to_radians()

static double xtd::math::degrees_to_radians ( double  degrees)
static

Convert degrees to radians.

Parameters
degreesA double-precision floating-point number.
Returns
A converted degrees from radians.

◆ div_rem() [1/2]

static int32_t xtd::math::div_rem ( int32_t  dividend,
int32_t  divisor,
int32_t &  remainder 
)
static

Calculates the quotient of two 32-bit signed integers and also returns the remainder in an output parameter.

Parameters
dividendThe dividend.
divisorThe divisor.
remainderAn angle, measured in radians.
Returns
The remainder.

◆ div_rem() [2/2]

static int64_t xtd::math::div_rem ( int64_t  dividend,
int64_t  divisor,
int64_t &  remainder 
)
static

Calculates the quotient of two 64-bit signed integers and also returns the remainder in an output parameter.

Parameters
dividendThe dividend.
divisorThe divisor.
remainderAn angle, measured in radians.
Returns
The remainder.

◆ exp()

static double xtd::math::exp ( double  value)
static

Returns e raised to the specified power.

Parameters
valueA number specifying a power.
Returns
The number e raised to the power d. If value equals xtd::math::NaN or xtd::math::positive_infinity, that value is returned. If value equals xtd::math::negative_infinity, 0 is returned.

◆ floor() [1/2]

static decimal_t xtd::math::floor ( decimal_t  value)
static

Returns the largest integer less than or equal to the specified decimal number.

Parameters
valueA double-precision floating-point number.
Returns
The largest integer less than or equal to value.

◆ floor() [2/2]

static double xtd::math::floor ( double  value)
static

Returns the largest integer less than or equal to the specified decimal number.

Parameters
valueA double-precision floating-point number.
Returns
The largest integer less than or equal to value.

◆ ieee_remainder()

static double xtd::math::ieee_remainder ( double  dividend,
double  divisor 
)
static

Returns the remainder resulting from the division of a specified number by another specified number.

Parameters
dividendA dividend.
divisorA divisor.
Returns
A number equal to x - (y Q), where Q is the quotient of x / y rounded to the nearest integer (if x / y falls halfway between two integers, the even integer is returned).
  • If x - (y Q) is zero, the value +0 is returned if x is positive, or -0 if x is negative.
  • If y = 0, xtd::math::NaN is returned.

◆ is_infinity()

static bool xtd::math::is_infinity ( double  value)
static

Returns a value indicating whether the specified number evaluates to negative or positive infinity.

Parameters
valueA double-precision floating-point number.
Returns
true if value evaluates to xtd::math::positive_infinity or xtd::math::negative_infinity; otherwise, false.

◆ is_NaN()

static bool xtd::math::is_NaN ( double  value)
static

Returns a value indicating whether the specified number evaluates to not a number.

Parameters
valueA double-precision floating-point number.
Returns
true if value evaluates to not a number; otherwise, false.

◆ is_negative_infinity()

static bool xtd::math::is_negative_infinity ( double  value)
static

Returns a value indicating whether the specified number evaluates to negative infinity.

Parameters
valueA double-precision floating-point number.
Returns
true if value evaluates to xtd::math::negative_infinity; otherwise, false.

◆ is_positive_infinity()

static bool xtd::math::is_positive_infinity ( double  value)
static

Returns a value indicating whether the specified number evaluates to positive infinity.

Parameters
valueA double-precision floating-point number.
Returns
true if value evaluates to xtd::math::positive_infinity; otherwise, false.

◆ log() [1/2]

static double xtd::math::log ( double  value)
static

Returns the natural (base e) logarithm of a specified number.

Parameters
valueA number whose logarithm is to be found.
Returns
One of the values in the following table.
value parameter Return value
Positive The natural logarithm of d; that is, ln value, or log e value
Zero xtd::math::negative_infinity
Negative xtd::math::NaN
Equal to xtd::math::NaN xtd::math::NaN
Equal to xtd::math::positive_infinity xtd::math::positive_infinity
Remarks
Parameter value is specified as a base 10 number.

◆ log() [2/2]

static double xtd::math::log ( double  a,
double  new_base 
)
static

Returns the logarithm of a specified number in a specified base.

Parameters
aThe number whose logarithm is to be found.
new_baseThe base of the logarithm.
Returns
One of the values in the following table. (+Infinity denotes math::positive_infinity, -Infinity denotes math::negative_infinity, and math::NaN denotes math::NaN.)
a new_base Return value
a > 0 (0 < new_base < 1) -or- (new_base > 1) log new_base (a)
a < 0 (any value) xtd::math::NaN
(any value) new_base < 0 xtd::math::NaN
a != 1 new_base = 0 xtd::math::NaN
a != 1 new_base = xtd::math::positive_infinity xtd::math::NaN
a = xtd::math::NaN (any value) xtd::math::NaN
(any value) new_base = xtd::math::NaN xtd::math::NaN
(any value) new_base = 1 xtd::math::NaN
a = 0 0 < new_base < 1 xtd::math::positive_infinity
a = 0 new_base > 1 xtd::math::negative_infinity
a = xtd::math::positive_infinity 0 < new_base < 1 xtd::math::negative_infinity
a = xtd::math::positive_infinity new_base > 1 xtd::math::positive_infinity
a = 1 new_base = 0 0
a = 1 new_base = xtd::math::positive_infinity 0

◆ log10()

static double xtd::math::log10 ( double  value)
static

Returns the base 10 logarithm of a specified number.

Parameters
valueA number whose logarithm is to be found.
Returns
One of the values in the following table.
value parameter Return value
Positive The natural logarithm of d; that is, ln value, or log e value
Zero xtd::math::negative_infinity
Negative xtd::math::NaN
Equal to xtd::math::NaN xtd::math::NaN
Equal to xtd::math::positive_infinity xtd::math::positive_infinity
Remarks
Parameter value is specified as a base 10 number.

◆ max() [1/13]

static byte_t xtd::math::max ( byte_t  a,
byte_t  b 
)
static

Returns the larger of two 8-bit unsigned integers.

Parameters
aThe first of two 8-bit unsigned integers to compare.
bThe second of two 8-bit unsigned integers to compare.
Returns
Parameter a or b, whichever is larger.

◆ max() [2/13]

static decimal_t xtd::math::max ( decimal_t  a,
decimal_t  b 
)
static

Returns the larger of two double single.

Parameters
aThe first of two double single to compare.
bThe second of two double single to compare.
Returns
Parameter a or b, whichever is larger.

◆ max() [3/13]

static double xtd::math::max ( double  a,
double  b 
)
static

Returns the larger of two double single.

Parameters
aThe first of two double single to compare.
bThe second of two double single to compare.
Returns
Parameter a or b, whichever is larger.

◆ max() [4/13]

static int16_t xtd::math::max ( int16_t  a,
int16_t  b 
)
static

Returns the larger of two 16-bit signed integers.

Parameters
aThe first of two 16-bit signed integers to compare.
bThe second of two 16-bit signed integers to compare.
Returns
Parameter a or b, whichever is larger.

◆ max() [5/13]

static int32_t xtd::math::max ( int32_t  a,
int32_t  b 
)
static

Returns the larger of two 32-bit signed integers.

Parameters
aThe first of two 32-bit signed integers to compare.
bThe second of two 32-bit signed integers to compare.
Returns
Parameter a or b, whichever is larger.

◆ max() [6/13]

static int64_t xtd::math::max ( int64_t  a,
int64_t  b 
)
static

Returns the larger of two 64-bit signed integers.

Parameters
aThe first of two 64-bit signed integers to compare.
bThe second of two 64-bit signed integers to compare.
Returns
Parameter a or b, whichever is larger.

◆ max() [7/13]

static llong_t xtd::math::max ( llong_t  a,
llong_t  b 
)
static

Returns the larger of two 64-bit signed integers.

Parameters
aThe first of two 64-bit signed integers to compare.
bThe second of two 64-bit signed integers to compare.
Returns
Parameter a or b, whichever is larger.

◆ max() [8/13]

static sbyte_t xtd::math::max ( sbyte_t  a,
sbyte_t  b 
)
static

Returns the larger of two 8-bit signed integers.

Parameters
aThe first of two 8-bit signed integers to compare.
bThe second of two 8-bit signed integers to compare.
Returns
Parameter a or b, whichever is larger.

◆ max() [9/13]

static float xtd::math::max ( float  a,
float  b 
)
static

Returns the larger of two single single.

Parameters
aThe first of two signle single to compare.
bThe second of two single single to compare.
Returns
Parameter a or b, whichever is larger.

◆ max() [10/13]

static uint16_t xtd::math::max ( uint16_t  a,
uint16_t  b 
)
static

Returns the larger of two 16-bit unsigned integers.

Parameters
aThe first of two 16-bit unsigned integers to compare.
bThe second of two 16-bit unsigned integers to compare.
Returns
Parameter a or b, whichever is larger.

◆ max() [11/13]

static uint32_t xtd::math::max ( uint32_t  a,
uint32_t  b 
)
static

Returns the larger of two 32-bit unsigned integers.

Parameters
aThe first of two 32-bit unsigned integers to compare.
bThe second of two 32-bit unsigned integers to compare.
Returns
Parameter a or b, whichever is larger.

◆ max() [12/13]

static uint64_t xtd::math::max ( uint64_t  a,
uint64_t  b 
)
static

Returns the larger of two 64-bit unsigned integers.

Parameters
aThe first of two 64-bit unsigned integers to compare.
bThe second of two 64-bit unsigned integers to compare.
Returns
Parameter a or b, whichever is larger.

◆ max() [13/13]

static ullong_t xtd::math::max ( ullong_t  a,
ullong_t  b 
)
static

Returns the larger of two 64-bit unsigned integers.

Parameters
aThe first of two 64-bit unsigned integers to compare.
bThe second of two 64-bit unsigned integers to compare.
Returns
Parameter a or b, whichever is larger.

◆ min() [1/13]

static byte_t xtd::math::min ( byte_t  a,
byte_t  b 
)
static

Returns the smaller of two 8-bit unsigned integers.

Parameters
aThe first of two 8-bit unsigned integers to compare.
bThe second of two 8-bit unsigned integers to compare.
Returns
Parameter a or b, whichever is smaller.

◆ min() [2/13]

static decimal_t xtd::math::min ( decimal_t  a,
decimal_t  b 
)
static

Returns the smaller of two double single.

Parameters
aThe first of two double single to compare.
bThe second of two double single to compare.
Returns
Parameter a or b, whichever is smaller.

◆ min() [3/13]

static double xtd::math::min ( double  a,
double  b 
)
static

Returns the smaller of two double single.

Parameters
aThe first of two double single to compare.
bThe second of two double single to compare.
Returns
Parameter a or b, whichever is smaller.

◆ min() [4/13]

static int16_t xtd::math::min ( int16_t  a,
int16_t  b 
)
static

Returns the smaller of two 16-bit signed integers.

Parameters
aThe first of two 16-bit signed integers to compare.
bThe second of two 16-bit signed integers to compare.
Returns
Parameter a or b, whichever is smaller.

◆ min() [5/13]

static int32_t xtd::math::min ( int32_t  a,
int32_t  b 
)
static

Returns the smaller of two 32-bit signed integers.

Parameters
aThe first of two 32-bit signed integers to compare.
bThe second of two 32-bit signed integers to compare.
Returns
Parameter a or b, whichever is smaller.

◆ min() [6/13]

static int64_t xtd::math::min ( int64_t  a,
int64_t  b 
)
static

Returns the smaller of two 64-bit signed integers.

Parameters
aThe first of two 64-bit signed integers to compare.
bThe second of two 64-bit signed integers to compare.
Returns
Parameter a or b, whichever is smaller.

◆ min() [7/13]

static llong_t xtd::math::min ( llong_t  a,
llong_t  b 
)
static

Returns the smaller of two 64-bit signed integers.

Parameters
aThe first of two 64-bit signed integers to compare.
bThe second of two 64-bit signed integers to compare.
Returns
Parameter a or b, whichever is smaller.

◆ min() [8/13]

static sbyte_t xtd::math::min ( sbyte_t  a,
sbyte_t  b 
)
static

Returns the smaller of two 8-bit signed integers.

Parameters
aThe first of two 8-bit signed integers to compare.
bThe second of two 8-bit signed integers to compare.
Returns
Parameter a or b, whichever is smaller.

◆ min() [9/13]

static float xtd::math::min ( float  a,
float  b 
)
static

Returns the smaller of two single single.

Parameters
aThe first of two signle single to compare.
bThe second of two single single to compare.
Returns
Parameter a or b, whichever is smaller.

◆ min() [10/13]

static uint16_t xtd::math::min ( uint16_t  a,
uint16_t  b 
)
static

Returns the smaller of two 16-bit unsigned integers.

Parameters
aThe first of two 16-bit unsigned integers to compare.
bThe second of two 16-bit unsigned integers to compare.
Returns
Parameter a or b, whichever is smaller.

◆ min() [11/13]

static uint32_t xtd::math::min ( uint32  a,
uint32  b 
)
static

Returns the smaller of two 32-bit unsigned integers.

Parameters
aThe first of two 32-bit unsigned integers to compare.
bThe second of two 32-bit unsigned integers to compare.
Returns
Parameter a or b, whichever is smaller.

◆ min() [12/13]

static uint64 xtd::math::min ( uint64_t  a,
uint64_t  b 
)
static

Returns the smaller of two 64-bit unsigned integers.

Parameters
aThe first of two 64-bit unsigned integers to compare.
bThe second of two 64-bit unsigned integers to compare.
Returns
Parameter a or b, whichever is smaller.

◆ min() [13/13]

static ullong_t xtd::math::min ( ullong_t  a,
ullong_t  b 
)
static

Returns the smaller of two 64-bit unsigned integers.

Parameters
aThe first of two 64-bit unsigned integers to compare.
bThe second of two 64-bit unsigned integers to compare.
Returns
Parameter a or b, whichever is smaller.

◆ pow()

static double xtd::math::pow ( double  x,
double  y 
)
static

Returns a specified number raised to the specified power.

Parameters
xA double-precision floating-point number to be raised to a power.
yA double-precision floating-point number that specifies a power.
Returns
The number x raised to the power y.
Remarks
The following table indicates the return value when various values or ranges of values are specified for the x and y parameters. For more information, see Double::math::positive_infinity, Double::math::negative_infinity, and Double::NaN.
Parameters Return value
x or y = math::NaN. math::NaN
x = Any value except math::NaN; y = 0. 1
x = math::negative_infinity; y < 0. 0
x = math::negative_infinity; y is positive odd integer. math::negative_infinity
x = math::negative_infinity; y is positive but not an odd integer. math::positive_infinity
x < 0 but not math::negative_infinity; y is not an integer, math::negative_infinity, or math::positive_infinity. math::NaN
x = -1; y = math::negative_infinity or math::positive_infinity. math::NaN
-1 < x < 1; y = math::negative_infinity. math::positive_infinity
-1 < x < 1; y = math::positive_infinity. 0
x < -1 or x > 1; y = math::negative_infinity. 0
x < -1 or x > 1; y = math::positive_infinity. math::positive_infinity
x = 0; y < 0. math::positive_infinity
x = 0; y > 0. 0
x = 1; y is any value except math::NaN. 1
x = math::positive_infinity; y < 0 0
x = math::positive_infinity; y > 0. math::positive_infinity

◆ radians_to_degrees()

static double xtd::math::radians_to_degrees ( double  radians)
static

Convert radians to degrees.

Parameters
radiansA double-precision floating-point number.
Returns
A converted radians from degrees.

◆ round() [1/4]

static decimal_t xtd::math::round ( decimal_t  value)
static

Rounds a double-precision floating-point value to the nearest integral value.

Parameters
valueA double-precision floating-point number to be rounded.
Returns
The integer nearest value. If the fractional component of a is halfway between two integers, one of which is even and the other odd, then the even number is returned. Note that this method returns a double instead of an integral type.

◆ round() [2/4]

static decimal_t xtd::math::round ( decimal_t  value,
int32_t  decimals 
)
static

Rounds a decimal value to a specified number of fractional digits.

Parameters
valueA double-precision floating-point number to be rounded.
decimalsThe number of decimal places in the return value.
Returns
The number nearest to d that contains a number of fractional digits equal to decimals.

◆ round() [3/4]

static double xtd::math::round ( double  value)
static

Rounds a double-precision floating-point value to the nearest integral value.

Parameters
valueA double-precision floating-point number to be rounded.
Returns
The integer nearest value. If the fractional component of a is halfway between two integers, one of which is even and the other odd, then the even number is returned. Note that this method returns a double instead of an integral type.

◆ round() [4/4]

static double xtd::math::round ( double  value,
int32_t  decimals 
)
static

Rounds a decimal value to a specified number of fractional digits.

Parameters
valueA double-precision floating-point number to be rounded.
decimalsThe number of decimal places in the return value.
Returns
The number nearest to d that contains a number of fractional digits equal to decimals.

◆ sign() [1/8]

static int32_t xtd::math::sign ( decimal_t  value)
static

Returns a value indicating the sign of a double-precision floating-point number.

Parameters
valueA signed number.
Returns
int32 A number that indicates the sign of value, as shown in the following table.
Return value Meaning
-1 value is less than zero.
0 value is equal to zero.
1 value is greater than zero.
Exceptions
xtd::arithmetic_exceptionvalue is equal to NaN.

◆ sign() [2/8]

static int32_t xtd::math::sign ( double  value)
static

Returns a value indicating the sign of a double-precision floating-point number.

Parameters
valueA signed number.
Returns
int32 A number that indicates the sign of value, as shown in the following table.
Return value Meaning
-1 value is less than zero.
0 value is equal to zero.
1 value is greater than zero.
Exceptions
xtd::arithmetic_exceptionvalue is equal to NaN.

◆ sign() [3/8]

static int32_t xtd::math::sign ( int16_t  value)
static

Returns a value indicating the sign of a 16-bit signed integer.

Parameters
valueA signed number.
Returns
int32 A number that indicates the sign of value, as shown in the following table.
Return value Meaning
-1 value is less than zero.
0 value is equal to zero.
1 value is greater than zero.

◆ sign() [4/8]

static int32_t xtd::math::sign ( int32_t  value)
static

Returns a value indicating the sign of a 32-bit signed integer.

Parameters
valueA signed number.
Returns
int32 A number that indicates the sign of value, as shown in the following table.
Return value Meaning
-1 value is less than zero.
0 value is equal to zero.
1 value is greater than zero.

◆ sign() [5/8]

static int32_t xtd::math::sign ( int64_t  value)
static

Returns a value indicating the sign of a 64-bit signed integer.

Parameters
valueA signed number.
Returns
int32 A number that indicates the sign of value, as shown in the following table.
Return value Meaning
-1 value is less than zero.
0 value is equal to zero.
1 value is greater than zero.

◆ sign() [6/8]

static int32_t xtd::math::sign ( llong_t  value)
static

Returns a value indicating the sign of a 64-bit signed integer.

Parameters
valueA signed number.
Returns
int32 A number that indicates the sign of value, as shown in the following table.
Return value Meaning
-1 value is less than zero.
0 value is equal to zero.
1 value is greater than zero.

◆ sign() [7/8]

static int32_t xtd::math::sign ( sbyte_t  value)
static

Returns a value indicating the sign of an 8-bit signed integer.

Parameters
valueA signed number.
Returns
int32 A number that indicates the sign of value, as shown in the following table.
Return value Meaning
-1 value is less than zero.
0 value is equal to zero.
1 value is greater than zero.

◆ sign() [8/8]

static int32_t xtd::math::sign ( float  value)
static

Returns a value indicating the sign of a single-precision floating-point number.

Parameters
valueA signed number.
Returns
int32 A number that indicates the sign of value, as shown in the following table.
Return value Meaning
-1 value is less than zero.
0 value is equal to zero.
1 value is greater than zero.
Exceptions
xtd::arithmetic_exceptionvalue is equal to NaN.

◆ sin()

static double xtd::math::sin ( double  value)
static

Returns the sine of the specified angle.

Parameters
valueAn angle, measured in radians.
Returns
double The sine of value. If value is equal to math::NaN, math::negative_infinity, or math::positiveI_infinity, this method returns math::NaN.

◆ sinh()

static double xtd::math::sinh ( double  value)
static

Returns the hyperbolic sine of the specified angle.

Parameters
valueAn angle, measured in radians.
Returns
double The sine of a. If a is equal to math::NaN, math::negative_infinity, or math::positive_infinity, this method returns math::NaN.

◆ sqrt()

static double xtd::math::sqrt ( double  value)
static

Returns the square root of a specified number.

Parameters
valueThe number whose square root is to be found.
Returns
One of the values in the following table.
value parameter Return value
Zero or positive The positive square root of d.
Negative math::NaN
Equals math::NaN math::NaN
Equals math::positive_infinity math::positive_infinity

◆ tan()

static double xtd::math::tan ( double  value)
static

Returns the tangent of the specified angle.

Parameters
valueAn angle, measured in radians.
Returns
The tangent of value. If value is equal to math::NaN, math::negative_infinity, or math::psitive_infinity, this method returns math::NaN.

◆ tanh()

static double xtd::math::tanh ( double  value)
static

Returns the hyperbolic tangent of the specified angle.

Parameters
valueAn angle, measured in radians.
Returns
The hyperbolic tangent of value. If value is equal to math::negative_infinity, this method returns -1. If value is equal to math::positive_infinity, this method returns 1. If value is equal to math::NaN, this method returns math::NaN.

◆ truncate() [1/2]

static decimal_t xtd::math::truncate ( decimal_t  value)
static

Calculates the integral part of a specified double-precision floating-point number.

Parameters
valueA number to truncate.
Returns
The integral part of d; that is, the number that remains after any fractional digits have been discarded, or one of the values listed in the following table.
value Return value
NaN NaN
NegativeInfinity NegativeInfinity
PositiveInfinity PositiveInfinity

◆ truncate() [2/2]

static double xtd::math::truncate ( double  value)
static

Calculates the integral part of a specified double-precision floating-point number.

Parameters
valueA number to truncate.
Returns
The integral part of d; that is, the number that remains after any fractional digits have been discarded, or one of the values listed in the following table.
value Return value
math::NaN math::NaN
math::negative_infinity math::negative_infinity
math::positive_infinity math::positive_infinity

Member Data Documentation

◆ e

constexpr double xtd::math::e = 2.7182818284590452354
static

Represents the natural logarithmic base, specified by the constant, e. This field is constant.

Remarks
The value of this field is 2.7182818284590452354.

◆ epsilon

constexpr double xtd::math::epsilon = 4.94066e-324
static

Represents the smallest positive Double value greater than zero. This field is constant.

Remarks
The value of this field is 4.94066e-324.

◆ infinity

constexpr double xtd::math::infinity = std::numeric_limits<double>::infinity()
static

Represents infinity. This field is constant.

Remarks
The value of this field is std::numeric_limits<double>::infinity().

◆ max_value

constexpr double xtd::math::max_value = std::numeric_limits<double>::max()
static

Represents the largest possible value of double. This field is constant.

Remarks
The value of this field is 1.7976931348623157E+308.

◆ min_value

constexpr double xtd::math::min_value = std::numeric_limits<double>::lowest()
static

Represents the smallest possible value of double. This field is constant.

Remarks
The value of this field is -1.7976931348623157E+308.

◆ NaN

constexpr double xtd::math::NaN = std::numeric_limits<double>::quiet_NaN()
static

Represents not a number (NaN). This field is constant.

Remarks
The value of this field is std::numeric_limits<double>::quiet_NaN().

◆ negative_infinity

constexpr double xtd::math::negative_infinity = -infinity
static

Represents negative infinity. This field is constant.

Remarks
The value of this field is -std::numeric_limits<double>::infinity().

◆ pi

constexpr double xtd::math::pi = 3.14159265358979323846
static

Represents the ratio of the circumference of a circle to its diameter, specified by the constant, π. This field is constant.

Remarks
The value of this field is 3.14159265358979323846.

◆ positive_infinity

constexpr double xtd::math::positive_infinity = +infinity
static

Represents positive infinity. This field is constant.

Remarks
The value of this field is std::numeric_limits<double>::infinity().

◆ tau

constexpr double xtd::math::tau = 2.7182818284590451
static

Represents the number of radians in one turn, specified by the constant, τ.

Remarks
The value of this field is 2.7182818284590451.

The documentation for this class was generated from the following file: