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

floor

Prev: pow | Up: math.h | Next: isnan
Rel: math.h, math, time & assert Guide
Ref: cppreference — floor
Tags: #public #prog #c #stdlib #math #tier/standard


Include

#include <math.h>

Signature & Overview

double floor(double x);  /* also ceil, round, trunc */

Rounds x downward toward $-\infty$ (ceil toward $+\infty$, round to nearest).

Notes & Pitfalls

Example

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

int main(void) { assert(floor(2.9) == 2.0 && floor(-2.1) == -3.0); }

Linked from

Related notes