std.math.rounding

This is a submodule of std.math.

It contains several functions for rounding floating point numbers.

Functions 21

fnreal ceil(real x) @trusted pure nothrow @nogcReturns the value of x rounded upward to the next integer (toward positive infinity).
fndouble ceil(double x) @trusted pure nothrow @nogcditto
fnfloat ceil(float x) @trusted pure nothrow @nogcditto
fnreal floor(real x) @trusted pure nothrow @nogcReturns the value of x rounded downward to the next integer (toward negative infinity).
fndouble floor(double x) @trusted pure nothrow @nogcditto
fnfloat floor(float x) @trusted pure nothrow @nogcditto
fnUnqual!F quantize(alias rfunc = rint, F)(const F val, const F unit) if (is(typeof(rfunc(F.init)) : F) && isFloatingPoint!F)Round `val` to a multiple of `unit`. `rfunc` specifies the rounding function to use; by default this is `rint`, which uses the current rounding mode.
fnUnqual!F quantize(real base, alias rfunc = rint, F, E)(const F val, const E exp) if (is(typeof(rfunc(F.init)) : F) && isFloatingPoint!F && isIntegral!E)Round `val` to a multiple of `pow(base, exp)`. `rfunc` specifies the rounding function to use; by default this is `rint`, which uses the current rounding mode.
fnUnqual!F quantize(real base, long exp = 1, alias rfunc = rint, F)(const F val) if (is(typeof(rfunc(F.init)) : F) && isFloatingPoint!F)ditto
fnreal nearbyint(real x) @safe pure nothrow @nogcRounds x to the nearest integer value, using the current rounding mode.
fnreal rint(real x) @safe pure nothrow @nogcRounds x to the nearest integer value, using the current rounding mode.
fndouble rint(double x) @safe pure nothrow @nogcditto
fnfloat rint(float x) @safe pure nothrow @nogcditto
fnlong lrint(real x) @trusted pure nothrow @nogcRounds x to the nearest integer value, using the current rounding mode.
fnauto round(real x) @trusted nothrow @nogcReturn the value of x rounded to the nearest integer. If the fractional part of x is exactly 0.5, the return value is rounded away from zero.
fnlong lround(real x) @trusted nothrow @nogcReturn the value of x rounded to the nearest integer.
fnreal trunc(real x) @trusted nothrow @nogc pureReturns the integer portion of x, dropping the fractional portion. This is also known as "chop" rounding. `pure` on all platforms.
fnlong rndtol(real x) @nogc @safe pure nothrowReturns x rounded to a long value using the current rounding mode. If the integer value of x is greater than long.max, the result is indeterminate.
fnlong rndtol(double x) @safe pure nothrow @nogcditto
fnlong rndtol(float x) @safe pure nothrow @nogcditto
fnT floorImpl(T)(const T x) @trusted pure nothrow @nogc