eris.decimal.math

Floating-point decimal mathematical functions.

An implementation of the General Decimal Arithmetic Specification.

Members

Functions

Constant
D Constant(int precision)

If a constant has already been calculated, this function attempts to use an existing value rather than recalculate. If the constant has not yet been calculated to the desired precision, returns false.

M_1_PI
D M_1_PI(Context inContext)

Calculates the value of 1/pi in the specified context.

M_2_PI
D M_2_PI(Context inContext)

Calculates the value of 1/pi in the specified context.

acos
T acos(T x)

Decimal version of std.math function.

acosh
T acosh(T x, Context inContext)

Decimal version of std.math function.

asin
T asin(T x)

Decimal version of std.math function.

asinh
T asinh(T x, Context inContext)

Decimal version of std.math function.

atan
T atan(T x, Context inContext)

Returns the arctangent of the argument in the specified context. Algorithm uses Taylor's theorem for arctangent.

atan2
TD atan2(T y, TD x)

Decimal version of std.math function.

atanh
T atanh(T x, Context inContext)

Decimal version of std.math function.

calcE
D calcE(int precision)

Calculates the value of e to the specified precision. Returns the calculated value.

calcPi
D calcPi(int precision)

Returns pi (3.14159265...) for the specified context.

ceil
T ceil(T x)

Returns the nearest integer greater than or equal to the argument. Rounds toward positive infinity.

changePrecision
Context changePrecision(Context context, int precision)

Changes the current precision and sets rounding to HALF_EVEN. This is useful for extended calculation to minimize errors. Returns a new context with the precision increased by the guard digits value. Note that this does not create a new Decimal type with this context.

cos
T cos(T x, int precision)

Decimal version of std.math function.

cos
T cos(T x, Context inContext)

Decimal version of std.math function. Precondition: x is in 1st quadrant.

cosh
T cosh(T x, Context inContext)

Decimal version of std.math function.

divTan
T divTan(T x)

Decimal version of std.math function.

e
D e(int precision)
Undocumented in source. Be warned that the author may not have intended to support it.
exp
D exp(D arg, int precision)

Returns the exponent of the argument at the specified precision.

exp
D exp(D num, Context context, int guardDigits)

Returns the exponent of the argument at the current precision. Decimal version of std.math function. Required by General Decimal Arithmetic Specification

expm1
T expm1(T x, Context inContext)

expm1(x) will be more accurate than exp(x) - 1 for x << 1. Decimal version of std.math function. Reference: Beebe, Nelson H. F., "Computation of expm1(x) = exp(x) - 1".

floor
T floor(T x)

Returns the nearest integer less than or equal to the argument. Rounds toward negative infinity.

guard
Context guard(Context context, int guardDigits)

Adds guard digits to the current precision and sets rounding to HALF_EVEN. This is useful for extended calculation to minimize errors. Returns a new context with the precision increased by the guard digits value. Note that this does not create a new Decimal type with this context.

hypot
T hypot(T x, T y, Context context)

Returns the square root of the sum of the squares in the specified context. Decimal version of std.math.hypot.

invSqrt
T invSqrt(T x, Context inContext)
Undocumented in source. Be warned that the author may not have intended to support it.
lbe
D lbe(int precision)

base 2 logarithm of e = 1.44269504...

ln10
D ln10(int precision)

natural logarithm of 10 = 2.30258509...

ln2
D ln2(int precision)

natural logarithm of 2 = 0.693147806...

log
D log(D arg, int precision)

Returns the logarithm of the argument at the specified precision.

log
D log(D num, Context context, bool reduceArg)
Undocumented in source. Be warned that the author may not have intended to support it.
log10
T log10(T x, Context inContext)

Decimal version of std.math.log10. Required by General Decimal Arithmetic Specification

log1p
T log1p(T x, Context inContext)

log1p (== log(1 + x)). Decimal version of std.math function.

log2
T log2(T x, Context inContext)

Decimal version of std.math.log2. Required by General Decimal Arithmetic Specification

pow
T pow(T x, T y)

Decimal version of std.math.pow. Required by General Decimal Arithmetic Specification

reciprocal
T reciprocal(T x, U precision)

Returns the value of the function at the specified precision.

reciprocal
T reciprocal(T x, Context inContext)
Undocumented in source. Be warned that the author may not have intended to support it.
rint
D rint(D num)

Rounds the argument to the nearest integer. If the argument is exactly half-way between two integers the even integer is returned.

sin
T sin(T x, int precision)

Decimal version of std.math function.

sin
T sin(T x, Context inContext)
Undocumented in source. Be warned that the author may not have intended to support it.
sincos
void sincos(T x, T sine, T cosine, int precision)
Undocumented in source. Be warned that the author may not have intended to support it.
sincos
void sincos(T x, T sine, T cosine, Context inContext)

Replaces std.math function expi

sinh
T sinh(T x, Context inContext)

Decimal version of std.math function.

sqrt
D sqrt(D arg, Context context)

Returns the square root of the argument to the current precision. Uses Newton's method.

sqrt2
D sqrt2(int precision)

Returns the square root of two (1.41421357...) at the specified precision.

tan
T tan(T x, int precision)
Undocumented in source. Be warned that the author may not have intended to support it.
tanh
T tanh(T x, Context inContext)

Decimal version of std.math function.

toBigInt
BigInt toBigInt(T x, Round mode)

Returns the nearest extended integer value. The value is rounded based on the specified rounding mode. The default mode is half-even.

toInt
int toInt(T x, Round mode)

Returns the nearest integer value. If the value is greater (less) than the maximum (minimum) int value the maximum (minimum) value is returned. The value is rounded based on the specified rounding mode. The default mode is half-even.

toLong
long toLong(T x, Round mode)

Returns the nearest long value. If the value is greater (less) than the maximum (minimum) long value the maximum (minimum) value is returned. The value is rounded based on the specified rounding mode. The default mode is half-even.

trunc
T trunc(T x)

Returns the truncated argument. Rounds toward zero.

Mixin templates

MCInit
mixintemplate MCInit(D, string str)
Undocumented in source.

Static functions

pi
D pi(int precision)

Returns pi (3.14159265...) at the specified precision. If the precision is less than or equal to a prior precision, the earlier calculated value is returned (rounded if needed). If the specified precision is higher than any previously calculated precision, then the constant is recalculated and the higher value is retained for subsequent use. Repeated calls to the function at the same precision perform no rounding or calculation.

Templates

BinaryFunction
template BinaryFunction(string name)
Undocumented in source.
UnaryFunction
template UnaryFunction(string name)
Undocumented in source.

Variables

M_E
D M_E(D);
Undocumented in source.
M_LN10
D M_LN10(D);
Undocumented in source.
M_LN2
D M_LN2(D);
Undocumented in source.
M_LOG10E
D M_LOG10E(D);
Undocumented in source.
M_LOG2E
D M_LOG2E(D);
Undocumented in source.
M_LOG2T
D M_LOG2T(D);
Undocumented in source.
M_LOGT2
D M_LOGT2(D);
Undocumented in source.
M_PI
D M_PI(D);
Undocumented in source.
M_SQRT2
D M_SQRT2(D);
Undocumented in source.
alpha
T alpha;
Undocumented in source.
context
auto context;
Undocumented in source.
context
auto context;
Undocumented in source.
log2T
T log2T;
Undocumented in source.

Meta

Authors

Paul D. Anderson

Standards

Conforms to the General Decimal Arithmetic Specification, Version 1.70, (25 March 2009).

License

<a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>