abs()
Anonymous contributor
Anonymous contributor2 total contributions
Anonymous contributor
Published Oct 23, 2023
Contribute to Docs
The abs()
function in Lua’s math library returns the absolute value of a given number.
Syntax
math.abs(number)
number
: The number to be addressed.
Example
This example demonstrates a basic implementation of math.abs()
.
local x = -5local answer = math.abs(x)local output = string.format("Absolute value %.0f is %.4f", x, answer)print(output)
This will result in the following output below.
Absolute value -5 is 5.0000
All contributors
- Anonymous contributorAnonymous contributor2 total contributions
- Anonymous contributor
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.