fabs()

Christine_Yang269 total contributions
Published Jul 20, 2021Updated Jun 20, 2023
Contribute to Docs
The fabs
function returns the absolute value of the floating point argument.
Syntax
std:fabs(n)
Example 1
Use fabs()
to return the absolute value of -6.5
:
#include <iostream>#include <cmath>int main() {std::cout << std::fabs(-6.5) << "\n";// Output: 6.5}
Codebyte Example
The following code example returns the absolute value of a decimal with the fabs()
method.
All contributors
- Christine_Yang269 total contributions
- garanews209 total contributions
- christian.dinh2481 total contributions
- Anonymous contributorAnonymous contributor3077 total contributions
- StevenSwiniarski466 total contributions
- yash.ladekar7 total contributions
- Christine_Yang
- garanews
- christian.dinh
- Anonymous contributor
- StevenSwiniarski
- yash.ladekar
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.