copysign

Copies the sign of a _decimal value to another. This operation is silent, no error flags are set and no exceptions are thrown.

@IEEECompliant("copySign", 23)
D1
copysign
(
D1
D2
)
(
auto const ref D1 to
,
auto const ref D2 from
)
if (
isDecimal!(D1, D2)
)

Parameters

to D1

a _decimal value to copy

from D2

a _decimal value from which the sign is copied

Return Value

Type: D1

to with the sign of from

Examples

decimal32 negative = -decimal32.min_normal;
decimal64 test = decimal64.max;
assert(copysign(test, negative) == -decimal64.max);

Meta