Note about branchless or abs-based mathx.sign

This commit is contained in:
Max Cahill 2021-06-29 14:44:09 +10:00
parent fe135c533b
commit a2c7800290

View File

@ -46,6 +46,7 @@ function mathx.to_precision(v, decimal_points)
end
--0, 1, -1 sign of a scalar
--todo: investigate if a branchless or `/abs` approach is faster in general case
function mathx.sign(v)
if v < 0 then return -1 end
if v > 0 then return 1 end