std.math.operations

This is a submodule of std.math.

It contains several functions for work with floating point numbers.

Members

Functions

NaN
real NaN(ulong payload)

Create a quiet NaN, storing an integer inside the payload.

approxEqual
deprecated bool approxEqual(T value, U reference, V maxRelDiff, V maxAbsDiff)

Computes whether a values is approximately equal to a reference value, admitting a maximum relative difference, and a maximum absolute difference.

cmp
int cmp(const(T) x, const(T) y)

Defines a total order on all floating-point numbers.

fdim
real fdim(real x, real y)

Returns the positive difference between x and y.

feqrel
int feqrel(X x, X y)

To what precision is x equal to y?

fma
real fma(real x, real y, real z)

Returns (x * y) + z, rounding only once according to the current rounding mode.

fmax
F fmax(F x, F y)

Returns the larger of x and y.

fmin
F fmin(F x, F y)

Returns the smaller of x and y.

getNaNPayload
ulong getNaNPayload(real x)

Extract an integral payload from a NaN.

isClose
bool isClose(T lhs, U rhs, V maxRelDiff, V maxAbsDiff)

Computes whether two values are approximately equal, admitting a maximum relative difference, and a maximum absolute difference.

nextDown
real nextDown(real x)
double nextDown(double x)
float nextDown(float x)

Calculate the next smallest floating point value before x.

nextUp
real nextUp(real x)
double nextUp(double x)
float nextUp(float x)

Calculate the next largest floating point value after x.

nextafter
T nextafter(T x, T y)

Calculates the next representable value after x in the direction of y.

Meta

Authors

Walter Bright, Don Clugston, Conversion of CEPHES math library to D by Iain Buclaw and David Nadlinger