sgn

Determines if x is negative This operation is silent, no error flags are set and no exceptions are thrown.

@safe pure nothrow @nogc
D
sgn
(
D : Decimal!bits
int bits
)
(
auto const ref D x
)

Parameters

x D

a _decimal value

Return Value

Type: D

-1.0 if x is negative, 0.0 if x is zero, 1.0 if x is positive

Examples

assert(sgn(decimal32.max) == 1);
assert(sgn(-decimal32.max) == -1);
assert(sgn(decimal64(0)) == 0);

Meta