bcabs — Returns the absolute value of an arbitrary precision number.
bcabs(string $num, ?int $scale = null): stringThe absolute value of a number num is the non-negative value of num without regard to its sign. Namely, num if num is a positive number, and -num if num is negative (in which case negating num makes -num positive).
For example, the absolute value of 3 is 3, and the absolute value of
−3 is also 3. The absolute value of a number may be thought of as its
distance from zero.
num : The number to get the absolute value of.
scale : The number of digits after the decimal place in the result. If null, it will default to the default scale set with bcscale(), or fallback to the value of the bcmath.scale INI directive.
The absolute value of num, as a string.
This function throws a ValueError in the following cases:
- num is not a well-formed BCMath numeric string.
- scale is outside the valid range.