nonZeroSign property

int nonZeroSign

The sign of this integer.

Like sign except that it returns 1 for zero (considering it positive).

Example:

5.nonZeroSign == 1
0.nonZeroSign == 1
(-2).nonZeroSign == -1

Implementation

int get nonZeroSign => isNegative ? -1 : 1;