toPrec

fnT toPrec(T: float)(float f) @nogc nothrow @safe pure

Round argument to a specific precision.

D language types specify only a minimum precision, not a maximum. The toPrec() function forces rounding of the argument f to the precision of the specified floating point type T. The rounding mode used is inevitably target-dependent, but will be done in a way to maximize accuracy. In most cases, the default is round-to-nearest.

Parameters

Tprecision type to round to
fvalue to convert

Returns

f in precision of type T
fnT toPrec(T: float)(double f) @nogc nothrow @safe pure

ditto

fnT toPrec(T: float)(real f) @nogc nothrow @safe pure

ditto

fnT toPrec(T: double)(float f) @nogc nothrow @safe pure

ditto

fnT toPrec(T: double)(double f) @nogc nothrow @safe pure

ditto

fnT toPrec(T: double)(real f) @nogc nothrow @safe pure

ditto

fnT toPrec(T: real)(float f) @nogc nothrow @safe pure

ditto

fnT toPrec(T: real)(double f) @nogc nothrow @safe pure

ditto

fnT toPrec(T: real)(real f) @nogc nothrow @safe pure

ditto