activemq-cpp-3.4.0

decaf::lang::Math Class Reference

The class Math contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions. More...

#include <src/main/decaf/lang/Math.h>

Public Member Functions

 Math ()
virtual ~Math ()

Static Public Member Functions

static int abs (int value)
 Returns the absolute value of an int value.
static long long abs (long long value)
 Returns the absolute value of an long long value.
static float abs (float value)
 Returns the absolute value of a float value.
static double abs (double value)
 Returns the absolute value of a double value.
static double sqrt (double value)
 Returns the arc cosine of an angle, in the range of 0.0 through pi.
static double pow (double base, double exp)
 Returns the value of the first argument raised to the power of the second argument.
static short min (short a, short b)
 Returns the double value that is closest in value to the argument and is equal to a mathematical integer.
static int min (int a, int b)
 Returns the smaller of two int values.
static unsigned int min (unsigned int a, unsigned int b)
 Returns the smaller of two unsigned int values.
static long long min (long long a, long long b)
 Returns the smaller of two long long values.
static float min (float a, float b)
 Returns the smaller of two float values.
static double min (double a, double b)
 Returns the smaller of two double values.
static short max (short a, short b)
 Returns the larger of two short values.
static int max (int a, int b)
 Returns the larger of two int values.
static long long max (long long a, long long b)
 Returns the larger of two long long values.
static float max (float a, float b)
 Returns the greater of two float values.
static double max (double a, double b)
 Returns the greater of two double values.
static double ceil (double value)
 Returns the natural logarithm (base e) of a double value.
static double floor (double value)
 Returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer.
static int round (float value)
 Returns the closest int to the argument.
static long long round (double value)
 Returns the closest long long to the argument.
static double random ()
 Computes the remainder operation on two arguments as prescribed by the IEEE 754 standard.
static float signum (float value)
 Returns Euler's number e raised to the power of a double value.
static double signum (double value)
 Returns the signum function of the argument; zero if the argument is zero, 1.0f if the argument is greater than zero, -1.0f if the argument is less than zero.
static double toRadians (double angdeg)
 Returns the measure in radians of the supplied degree angle.
static double toDegrees (double angrad)
 Returns the measure in degrees of the supplied radian angle.

Static Public Attributes

static const double E
static const double PI

Detailed Description

The class Math contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions.


Constructor & Destructor Documentation

decaf::lang::Math::Math ( ) [inline]
virtual decaf::lang::Math::~Math ( ) [inline, virtual]

Member Function Documentation

static int decaf::lang::Math::abs ( int  value) [inline, static]

Returns the absolute value of an int value.

If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned.

Parameters:
value- the value to return the abs of
Returns:
the value if positive, otherwise the negative of value
static long long decaf::lang::Math::abs ( long long  value) [inline, static]

Returns the absolute value of an long long value.

If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned.

Parameters:
value- the value to return the abs of
Returns:
the value if positive, otherwise the negative of value
static double decaf::lang::Math::abs ( double  value) [static]

Returns the absolute value of a double value.

If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned. Special cases:

o If the argument is positive zero or negative zero, the result is positive zero. o If the argument is infinite, the result is positive infinity. o If the argument is NaN, the result is NaN.

In other words, the result is the same as the value of the expression: Double::longBitsToDouble( 0x7fffffffffffffffULL & Double::doubleToLongBits( value ) )

Parameters:
value- the value to return the abs of
Returns:
the value if positive, otherwise the negative of value
static float decaf::lang::Math::abs ( float  value) [static]

Returns the absolute value of a float value.

If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned. Special cases:

o If the argument is positive zero or negative zero, the result is positive zero. o If the argument is infinite, the result is positive infinity. o If the argument is NaN, the result is NaN.

In other words, the result is the same as the value of the expression: Float::intBitsToFloat( 0x7fffffff & Float::floatToIntBits( value ) )

Parameters:
value- the value to return the abs of
Returns:
the value if positive, otherwise the negative of value
static double decaf::lang::Math::ceil ( double  value) [static]

Returns the natural logarithm (base e) of a double value.

Special cases:

o If the argument is NaN or less than zero, then the result is NaN. o If the argument is positive infinity, then the result is positive infinity. o If the argument is positive zero or negative zero, then the result is negative infinity.

Parameters:
valuethe value to compute the natural log of.
Returns:
the natural log of value. Returns the base 10 logarithm of a double value. Special cases:

o If the argument is NaN or less than zero, then the result is NaN. o If the argument is positive infinity, then the result is positive infinity. o If the argument is positive zero or negative zero, then the result is negative infinity. o If the argument is equal to 10n for integer n, then the result is n.

Parameters:
value- the value to operate on
Returns:
the long base 10 of value Returns the natural logarithm of the sum of the argument and 1. Note that for small values x, the result of log1p(x) is much closer to the true result of ln(1 + x) than the floating-point evaluation of log(1.0+x).

Special cases:

o If the argument is NaN or less than -1, then the result is NaN. o If the argument is positive infinity, then the result is positive infinity. o If the argument is negative one, then the result is negative infinity. o If the argument is zero, then the result is a zero with the same sign as the argument.

Parameters:
value- the value to operate on
Returns:
the the value ln(x + 1), the natural log of x + 1 Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer. Special cases:

o If the argument value is already equal to a mathematical integer, then the result is the same as the argument. o If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument. o If the argument value is less than zero but greater than -1.0, then the result is negative zero.

Note that the value of Math.ceil(x) is exactly the value of -Math.floor(-x).

Parameters:
value- the value to find the ceiling of
Returns:
the smallest (closest to negative infinity) floating-point value that is greater than or equal to the argument and is equal to a mathematical integer.
static double decaf::lang::Math::floor ( double  value) [static]

Returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer.

Special cases:

o If the argument value is already equal to a mathematical integer, then the result is the same as the argument. o If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.

Parameters:
value- the value to find the floor of
Returns:
the largest (closest to positive infinity) floating-point value that less than or equal to the argument and is equal to a mathematical integer.
static float decaf::lang::Math::max ( float  a,
float  b 
) [static]

Returns the greater of two float values.

That is, the result is the argument closer to positive infinity. If the arguments have the same value, the result is that same value. If either value is NaN, then the result is NaN. Unlike the numerical comparison operators, this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other negative zero, the result is positive zero.

Parameters:
a- an argument.
b- another argument.
Returns:
the larger of a and b.
static double decaf::lang::Math::max ( double  a,
double  b 
) [static]

Returns the greater of two double values.

That is, the result is the argument closer to positive infinity. If the arguments have the same value, the result is that same value. If either value is NaN, then the result is NaN. Unlike the numerical comparison operators, this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other negative zero, the result is positive zero.

Parameters:
a- an argument.
b- another argument.
Returns:
the larger of a and b.
static short decaf::lang::Math::max ( short  a,
short  b 
) [inline, static]

Returns the larger of two short values.

That is, the result the argument closer to the value of Short::MAX_VALUE. If the arguments have the same value, the result is that same value.

Parameters:
a- an argument.
b- another argument.
Returns:
the larger of a and b.
static int decaf::lang::Math::max ( int  a,
int  b 
) [inline, static]

Returns the larger of two int values.

That is, the result the argument closer to the value of Integer::MAX_VALUE. If the arguments have the same value, the result is that same value.

Parameters:
a- an argument.
b- another argument.
Returns:
the larger of a and b.
static long long decaf::lang::Math::max ( long long  a,
long long  b 
) [inline, static]

Returns the larger of two long long values.

That is, the result the argument closer to the value of Long::MAX_VALUE. If the arguments have the same value, the result is that same value.

Parameters:
a- an argument.
b- another argument.
Returns:
the larger of a and b.
static int decaf::lang::Math::min ( int  a,
int  b 
) [inline, static]

Returns the smaller of two int values.

That is, the result the argument closer to the value of Integer::MIN_VALUE. If the arguments have the same value, the result is that same value.

Parameters:
a- an argument.
b- another argument.
Returns:
the smaller of a and b.
static unsigned int decaf::lang::Math::min ( unsigned int  a,
unsigned int  b 
) [inline, static]

Returns the smaller of two unsigned int values.

That is, the result the argument closer to the value of Integer::MIN_VALUE. If the arguments have the same value, the result is that same value.

Parameters:
a- an argument.
b- another argument.
Returns:
the smaller of a and b.
static long long decaf::lang::Math::min ( long long  a,
long long  b 
) [inline, static]

Returns the smaller of two long long values.

That is, the result the argument closer to the value of Long::MIN_VALUE. If the arguments have the same value, the result is that same value.

Parameters:
a- an argument.
b- another argument.
Returns:
the smaller of a and b.
static float decaf::lang::Math::min ( float  a,
float  b 
) [static]

Returns the smaller of two float values.

That is, the result is the value closer to negative infinity. If the arguments have the same value, the result is that same value. If either value is NaN, then the result is NaN. Unlike the numerical comparison operators, this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other is negative zero, the result is negative zero.

Parameters:
a- an argument.
b- another argument.
Returns:
the smaller of a and b.
static double decaf::lang::Math::min ( double  a,
double  b 
) [static]

Returns the smaller of two double values.

That is, the result is the value closer to negative infinity. If the arguments have the same value, the result is that same value. If either value is NaN, then the result is NaN. Unlike the numerical comparison operators, this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other is negative zero, the result is negative zero.

Parameters:
a- an argument.
b- another argument.
Returns:
the smaller of a and b.
static short decaf::lang::Math::min ( short  a,
short  b 
) [inline, static]

Returns the double value that is closest in value to the argument and is equal to a mathematical integer.

If two double values that are mathematical integers are equally close, the result is the integer value that is even. Special cases:

o If the argument value is already equal to a mathematical integer, then the result is the same as the argument. o If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.

Parameters:
value- the value to round to the nearest integer
Returns:
the rounded value Returns the smaller of two short values. That is, the result is the argument closer to the value of decaf.lang.Short::MIN_VALUE. If the arguments have the same value, the result is that same value.
Parameters:
a- an argument.
b- another argument.
Returns:
the smaller of a and b.

Referenced by decaf::util::concurrent::LinkedBlockingQueue< E >::drainTo().

static double decaf::lang::Math::pow ( double  base,
double  exp 
) [static]

Returns the value of the first argument raised to the power of the second argument.

Special cases:

o If the second argument is positive or negative zero, then the result is 1.0. o If the second argument is 1.0, then the result is the same as the first argument. o If the second argument is NaN, then the result is NaN. o If the first argument is NaN and the second argument is nonzero, then the result is NaN.

Parameters:
base- the base
exp- the exponent
Returns:
the base raised to the power of exp.
static double decaf::lang::Math::random ( ) [static]

Computes the remainder operation on two arguments as prescribed by the IEEE 754 standard.

The remainder value is mathematically equal to f1 - f2 × n, where n is the mathematical integer closest to the exact mathematical value of the quotient f1/f2, and if two mathematical integers are equally close to f1/f2, then n is the integer that is even. If the remainder is zero, its sign is the same as the sign of the first argument. Special cases:

o If either argument is NaN, or the first argument is infinite, or the second argument is positive zero or negative zero, then the result is NaN. o If the first argument is finite and the second argument is infinite, then the result is the same as the first argument.

Parameters:
f1- the dividend.
f2- the divisor
Returns:
the IEEE remainder of value Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. Returned values are chosen pseudorandomly with (approximately) uniform distribution from that range.

When this method is first called, it creates a single new pseudorandom-number generator; This new pseudorandom-number generator is used thereafter for all calls to this method and is used nowhere else.

This method is properly synchronized to allow correct use by more than one thread. However, if many threads need to generate pseudorandom numbers at a great rate, it may reduce contention for each thread to have its own pseudorandom-number generator.

Returns:
a pseudorandom double greater than or equal to 0.0 and less than 1.0.
static long long decaf::lang::Math::round ( double  value) [static]

Returns the closest long long to the argument.

The result is rounded to an integer by adding 1/2, taking the floor of the result, and casting the result to type long long. In other words, the result is equal to the value of the expression: (long long)Math.floor(a + 0.5d)

o If the argument is NaN, the result is 0. o If the argument is negative infinity or any value less than or equal to the value of Long::MIN_VALUE, the result is equal to the value of Long::MIN_VALUE. o If the argument is positive infinity or any value greater than or equal to the value of Long::MAX_VALUE, the result is equal to the value of Long::MAX_VALUE.

Parameters:
value- the value to round
Returns:
the value of the argument rounded to the nearest integral value.
static int decaf::lang::Math::round ( float  value) [static]

Returns the closest int to the argument.

The result is rounded to an integer by adding 1/2, taking the floor of the result, and casting the result to type int. In other words, the result is equal to the value of the expression: (int)Math.floor( a + 0.5f )

o If the argument is NaN, the result is 0. o If the argument is negative infinity or any value less than or equal to the value of Integer::MIN_VALUE, the result is equal to the value of Integer::MIN_VALUE. o If the argument is positive infinity or any value greater than or equal to the value of Integer::MAX_VALUE, the result is equal to the value of Integer::MAX_VALUE.

Parameters:
value- the value to round
Returns:
the value of the argument rounded to the nearest integral value.
static double decaf::lang::Math::signum ( double  value) [static]

Returns the signum function of the argument; zero if the argument is zero, 1.0f if the argument is greater than zero, -1.0f if the argument is less than zero.

Special Cases:

o If the argument is NaN, then the result is NaN. o If the argument is positive zero or negative zero, then the result is the same as the argument.

Parameters:
value- the floating-point value whose signum is to be returned
Returns:
the signum function of the argument
static float decaf::lang::Math::signum ( float  value) [static]

Returns Euler's number e raised to the power of a double value.

Special cases:

o If the argument is NaN, the result is NaN. o If the argument is positive infinity, then the result is positive infinity. o If the argument is negative infinity, then the result is positive zero.

Parameters:
value- the exponent to raise e to
Returns:
the value e^a, where e is the base of the natural logarithms. Returns e^x - 1. Note that for values of x near 0, the exact sum of expm1(x) + 1 is much closer to the true result of ex than exp(x). Special cases:

o If the argument is NaN, the result is NaN. o If the argument is positive infinity, then the result is positive infinity. o If the argument is negative infinity, then the result is -1.0. o If the argument is zero, then the result is a zero with the same sign as the argument.

Parameters:
value- the value to raise e^x - 1
Returns:
the value ex - 1. Returns sqrt(x^2 + y^2) without intermediate overflow or underflow. Special cases:

If either argument is infinite, then the result is positive infinity. If either argument is NaN and neither argument is infinite, then the result is NaN.

Parameters:
x- an argument
y- another argument
Returns:
the sqrt(x^2 + y^2) without intermediate overflow or underflow Returns the signum function of the argument; zero if the argument is zero, 1.0f if the argument is greater than zero, -1.0f if the argument is less than zero. Special Cases:

o If the argument is NaN, then the result is NaN. o If the argument is positive zero or negative zero, then the result is the same as the argument.

Parameters:
value- the floating-point value whose signum is to be returned
Returns:
the signum function of the argument
static double decaf::lang::Math::sqrt ( double  value) [static]

Returns the arc cosine of an angle, in the range of 0.0 through pi.

Special case:

o If the argument is NaN or its absolute value is greater than 1, then the result is NaN.

Parameters:
value- the value to return the arc cosine of.
Returns:
arc cosine of value in radians. Returns the arc sine of an angle, in the range of -pi/2 through pi/2. Special cases:

o If the argument is NaN or its absolute value is greater than 1, then the result is NaN. o If the argument is zero, then the result is a zero with the same sign as the argument.

Parameters:
value- the value to return the arc cosine of.
Returns:
arc cosine of value in radians. Returns the arc tangent of an angle, in the range of -pi/2 through pi/2. Special cases:

o If the argument is NaN, then the result is NaN. o If the argument is zero, then the result is a zero with the same sign as the argument.

Parameters:
value- the value to return the arc cosine of.
Returns:
arc tangent of value in radians. Converts rectangular coordinates (x, y) to polar (r, theta). This method computes the phase theta by computing an arc tangent of y/x in the range of -pi to pi. Special cases:

o If either argument is NaN, then the result is NaN. o If the first argument is positive zero and the second argument is positive, or the first argument is positive and finite and the second argument is positive infinity, then the result is positive zero. o If the first argument is negative zero and the second argument is positive, or the first argument is negative and finite and the second argument is positive infinity, then the result is negative zero. o If the first argument is positive zero and the second argument is negative, or the first argument is positive and finite and the second argument is negative infinity, then the result is the double value closest to pi. o If the first argument is negative zero and the second argument is negative, or the first argument is negative and finite and the second argument is negative infinity, then the result is the double value closest to -pi. o If the first argument is positive and the second argument is positive zero or negative zero, or the first argument is positive infinity and the second argument is finite, then the result is the double value closest to pi/2. o If the first argument is negative and the second argument is positive zero or negative zero, or the first argument is negative infinity and the second argument is finite, then the result is the double value closest to -pi/2. o If both arguments are positive infinity, then the result is the double value closest to pi/4. o If the first argument is positive infinity and the second argument is negative infinity, then the result is the double value closest to 3*pi/4. o If the first argument is negative infinity and the second argument is positive infinity, then the result is the double value closest to -pi/4. o If both arguments are negative infinity, then the result is the double value closest to -3*pi/4.

Parameters:
y- the ordinate coordinate
x- the abscissa coordinate
Returns:
the theta component of the point (r, theta) in polar coordinates that corresponds to the point (x, y) in Cartesian coordinates. Returns the cube root of a double value. For positive finite x, cbrt(-x) == -cbrt(x); that is, the cube root of a negative value is the negative of the cube root of that value's magnitude. Special cases:

o If the argument is NaN, then the result is NaN. o If the argument is infinite, then the result is an infinity with the same sign as the argument. o If the argument is zero, then the result is a zero with the same sign as the argument.

Parameters:
value- the double to compute the cube root of
Returns:
the cube root of value Returns the trigonometric cosine of an angle. Special cases:

o If the argument is NaN or an infinity, then the result is NaN.

Parameters:
value- an value in radians
Returns:
the cosine of the argument. Returns the hyperbolic cosine of a double value. The hyperbolic cosine of x is defined to be (ex + e-x)/2 where e is Euler's number. Special cases:

o If the argument is NaN, then the result is NaN. o If the argument is infinite, then the result is positive infinity. o If the argument is zero, then the result is 1.0.

Parameters:
value- the number whose hyperbolic cosine is to be found
Returns:
the hyperbolic cosine of value Returns the trigonometric sine of an angle. Special case:

o If the argument is NaN or an infinity, then the result is NaN. o If the argument is zero, then the result is a zero with the same sign as the argument.

Parameters:
value- the number whose sin is to be found
Returns:
the sine of value Returns the hyperbolic sine of a double value. The hyperbolic sine of x is defined to be (ex - e-x)/2 where e is Euler's number. Special cases:

o If the argument is NaN, then the result is NaN. o If the argument is infinite, then the result is an infinity with the same sign as the argument. o If the argument is zero, then the result is a zero with the same sign as the argument.

Parameters:
value- the number whose hyperbolic sin is to be found
Returns:
the hyperbolic sine of value Returns the trigonometric tangent of an angle. Special cases:

o If the argument is NaN or an infinity, then the result is NaN. o If the argument is zero, then the result is a zero with the same sign as the argument.

Parameters:
value- the number whose tangent is to be found
Returns:
the tangent of value Returns the hyperbolic tangent of a double value. The hyperbolic tangent of x is defined to be (ex - e-x)/(ex + e-x), in other words, sinh(x)/cosh(x). Note that the absolute value of the exact tanh is always less than 1. Special cases:

o If the argument is NaN, then the result is NaN. o If the argument is zero, then the result is a zero with the same sign as the argument. o If the argument is positive infinity, then the result is +1.0. o If the argument is negative infinity, then the result is -1.0.

Parameters:
value- the number whose hyperbolic tangent is to be found
Returns:
the hyperbolic cosine of value Returns the correctly rounded positive square root of a double value. Special cases:

o If the argument is NaN or less than zero, then the result is NaN. o If the argument is positive infinity, then the result is positive infinity. o If the argument is positive zero or negative zero, then the result is the same as the argument.

Otherwise, the result is the double value closest to the true mathematical square root of the argument value.

Parameters:
value- the value to find the square root of
thesquare root of the argument.
static double decaf::lang::Math::toDegrees ( double  angrad) [inline, static]

Returns the measure in degrees of the supplied radian angle.

Parameters:
angrad- an angle in radians
Returns:
the degree measure of the angle.
static double decaf::lang::Math::toRadians ( double  angdeg) [inline, static]

Returns the measure in radians of the supplied degree angle.

Parameters:
angdeg- an angle in degrees
Returns:
the radian measure of the angle.

Field Documentation

const double decaf::lang::Math::E [static]
const double decaf::lang::Math::PI [static]

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