Example:
assert(absUnsign(5) == 5);
assert(absUnsign(-5) == 5);
assert(absUnsign(int.min) == cast(uint)int.min);auto absUnsign(T)(T x) if (isIntegral!T)Returns the absolute value of an integral type as an unsigned type.
This function converts a signed or unsigned integral value to its absolute value represented as an unsigned type. For signed types, negative values are converted to positive. For unsigned types, the value is returned as-is.
This is a module-level free function for compatibility with std.bigint.
x | The integral value to convert |
Example:
assert(absUnsign(5) == 5);
assert(absUnsign(-5) == 5);
assert(absUnsign(int.min) == cast(uint)int.min);