Math

Math struct

Contains math functions. This is a static type with no instance services. You should never create instances of it by any means.

class Math

Methods

MethodDescription
static T Abs(T)Returns the absolute value of the specified value.
static Decimal Abs(const Decimal&)Returns the absolute value of a value represented by the specified Decimal object.
static double Acos(double)Calculates the arccosine of the specified value.
static double Asin(double)Calculates the arcsin of the specified value.
static double Atan(double)Calculates the arctan of the specified value.
static double Atan2(double, double)Calculates the arctan of the ration of the specified values.
static int64_t BigMul(int, int)Returns the full product of two 32-bit integers.
static Decimal Ceiling(const Decimal&)Returns the smallest integral value that is greater than or equal to the specified value.
static double Ceiling(double)Returns the smallest integral value that is greater than or equal to the specified value.
static double Cos(double)Calculates the cosine of the specified value.
static double Cosh(double)Calculates the hyperbolic cosine of the specified value.
static int DivRem(int, int, int&)Calculates the quotient of two 32-bit integers and the remainder.
static int64_t DivRem(int64_t, int64_t, int64_t&)Calculates the quotient of two 64-bit integers and the remainder.
static double Exp(double)Returns e constant raised to the specified power.
static Decimal Floor(const Decimal&)Returns the largest integral value that is less than or equal to the specified value.
static double Floor(double)Returns the largest integral value that is less than or equal to the specified value.
static double IEEERemainder(double, double)Returns the remainder resulting from the division of a specified number by another specified number.
static double Log(double)Returns the natural logarithm of the specified value.
static double Log(double, double)Returns the logarithm of the specified value in the specified base.
static double Log10(double)Returns the base-10 logarithm of the specified value.
static auto Max(T0, T1)Returns the greatest value out of two numeric ones specified.
static T0 Max(T0, T1)Returns the greatest value out of two numeric ones specified.
float Max_(float, float)Returns the largest single-precision floating point value out of the two specified.
double Max_(double, double)Returns the largest double-precision floating point value out of the two specified.
static auto Min(T0, T1)Returns the smallest value out of two numeric ones specified.
static T0 Min(T0, T1)Returns the smallest value out of two numeric ones specified.
float Min_(float, float)Returns the smallest single-precision floating point value out of the two specified.
double Min_(double, double)Returns the smallest double-precision floating point value out of the two specified.
static T Modulus(T, T)Calculates the remainder resulting from the division one specified value by another specified value.
static double Pow(double, double)Returns the specified value raised to the specified power.
static double Round(double)Rounds the specified value to the nearest integral value.
static double Round(double, int)Rounds the specified value to the nearest value with the specified number of fractional digits.
static double Round(double, MidpointRounding)Rounds the specified value to the nearest integral number. A parameter specifies the function’s behavior if the specified value is equally close to two nearest numbers.
static double Round(double, int, MidpointRounding)Rounds the specified value to the nearest value with the specified number of fractional digits. A parameter specifies the function’s behavior if the specified value is equally close to two nearest numbers.
static Decimal Round(const Decimal&)Rounds the specified value to the nearest integral value.
static Decimal Round(const Decimal&, int)Rounds the specified value to the nearest value with the specified number of fractional digits.
static Decimal Round(const Decimal&, MidpointRounding)Rounds the specified value to the nearest integral number. A parameter specifies the function’s behavior if the specified value is equally close to two nearest numbers.
static Decimal Round(const Decimal&, int, MidpointRounding)Rounds the specified value to the nearest value with the specified number of fractional digits. A parameter specifies the function’s behavior if the specified value is equally close to two nearest numbers.
static std::enable_if<std::is_integral<T>::value&&!std::is_unsigned<T>::value, int>::type Sign(T)Determines the sign of the specified signed integral value.
static std::enable_if<std::is_floating_point<T>::value, int>::type Sign(T)Determines the sign of the specified floating-point value.
static int Sign(const Decimal&)Determines the sign of the specified decimal value.
static double Sin(double)Calculates the sine of the specified value.
static double Sinh(double)Calculates the hyperbolic sine of the specified value.
static double Sqrt(double)Returns the square root of the specified value.
static double Tan(double)Calculates the tangen of the specified value.
static double Tanh(double)Calculates the hyperbolic tangen of the specified value.
static Decimal Truncate(const Decimal&)Returns the Decimal object representing a value that has integral part equal to that of the value represented by the specified Decimal object of the with all fractional digits discarded.
static double Truncate(double)Returns a double-precision floating point value that has integral part equal to that of the specified value with all fractional digits discarded.

Fields

FieldDescription
static ENatural logarithm’s base.
static NaNRepresents a not-a-number value.
static NegativeInfinityRepresents the negative infinity.
static PIThe number Pi constant.
static PositiveInfinityRepresents the positive infinity.

Remarks

#include "system/math.h"
#include <iostream>

int main()
{
  using namespace System;

  // Print the absolute values.
  for (int i = -1; i < 2; ++i)
  {
    std::cout << Math::Abs(i) << " ";
  }
  std::cout << std::endl;

  // Print the sine of PI/2 and the cosine of PI.
  std::cout << "sin(PI/2)=" << Math::Sin(Math::PI/2) << "; cos(PI)=" << Math::Cos(Math::PI) << std::endl;

  return 0;
}
/*
This code example produces the following output:
1 0 1
sin(PI/2)=1; cos(PI)=-1
*/

See Also