On this page
  1. fabs
  2. Include
  3. Signature & Overview
  4. Notes & Pitfalls
  5. Example

fabs

Prev: sqrt | Up: math.h | Next: pow
Rel: math.h, abs()
Ref: cppreference — fabs
Tags: #public #prog #c #stdlib #math #tier/core


Include

#include <math.h>

Signature & Overview

double fabs(double x);

Returns the absolute value of a floating-point number (never use integer abs() on floats).

Notes & Pitfalls

Example

#include <assert.h>
#include <math.h>

int main(void) { assert(fabs(-3.5) == 3.5); }

Linked from

Related notes