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

sqrt

Prev: math.h | Up: math.h | Next: fabs
Rel: math.h, math, time & assert Guide
Ref: cppreference — sqrt
Tags: #public #prog #c #stdlib #math #tier/core


Include

#include <math.h>

Signature & Overview

double sqrt(double x);  /* also sqrtf, sqrtl */

Computes the non-negative square root of x (returns NaN and sets EDOM if x < 0).

Notes & Pitfalls

Example

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

int main(void) { assert(fabs(sqrt(25.0) - 5.0) < 1e-9); }

Linked from

Related notes