std.math.operations

This is a submodule of std.math.

It contains several functions for work with floating point numbers.

Types 1

structFloatingPointBitpattern(T) if (isFloatingPoint!T)
Fields
int exponent
bool negative

Functions 18

fnreal NaN(ulong payload) @trusted pure nothrow @nogcCreate a quiet , storing an integer inside the payload.
fnulong getNaNPayload(real x) @trusted pure nothrow @nogcExtract an integral payload from a .
fnreal nextUp(real x) @trusted pure nothrow @nogcCalculate the next largest floating point value after x.
fndouble nextUp(double x) @trusted pure nothrow @nogcditto
fnfloat nextUp(float x) @trusted pure nothrow @nogcditto
fnreal nextDown(real x) @safe pure nothrow @nogcCalculate the next smallest floating point value before x.
fndouble nextDown(double x) @safe pure nothrow @nogcditto
fnfloat nextDown(float x) @safe pure nothrow @nogcditto
fnT nextafter(T)(const T x, const T y) @safe pure nothrow @nogcCalculates the next representable value after x in the direction of y.
fnreal fdim(real x, real y) @safe pure nothrow @nogcReturns the positive difference between x and y.
fnF fmax(F)(const F x, const F y) if (__traits(isFloating, F)) @safe pure nothrow @nogcReturns the larger of `x` and `y`.
fnF fmin(F)(const F x, const F y) if (__traits(isFloating, F)) @safe pure nothrow @nogcReturns the smaller of `x` and `y`.
fnreal fma(real x, real y, real z) @safe pure nothrow @nogcReturns (x * y) + z, rounding only once according to the current rounding mode.
fnint feqrel(X)(const X x, const X y) if (isFloatingPoint!(X)) @trusted pure nothrow @nogcTo what precision is x equal to y?
fnbool approxEqual(T, U, V)(T value, U reference, V maxRelDiff = 1e-2, V maxAbsDiff = 1e-5)
deprecated approxEqual will be removed in 2.106.0. Please use isClose instead.
Computes whether a values is approximately equal to a reference value, admitting a maximum relative difference, and a maximum absolute difference.
fnbool isClose(T, U, V = CommonType!(FloatingPointBaseType!T, FloatingPointBaseType!U))(T lhs, U rhs, V maxRelDiff = CommonDefaultFor!(T, U), V maxAbsDiff = 0.0)Computes whether two values are approximately equal, admitting a maximum relative difference, and a maximum absolute difference.
fnint cmp(T)(const(T) x, const(T) y) if (isFloatingPoint!T) @nogc @trusted pure nothrowDefines a total order on all floating-point numbers.
fnFloatingPointBitpattern!T extractBitpattern(T)(const(T) value) if (isFloatingPoint!T) @trusted

Templates 2

tmplCommonDefaultFor(T, U)
tmplFloatingPointBaseType(T)