Skip to content

Latest commit

 

History

History
57 lines (37 loc) · 1 KB

089_floor.asciidoc

File metadata and controls

57 lines (37 loc) · 1 KB

floor

NAME

floor - largest integer value not greater than x.

SYNOPSIS
#include <math.h>

double floor(double x);
DESCRIPTION

These function returns the largest integral value that is not greater than x. For example, floor(0.5) is 0.0, and floor(-0.5) is -1.0.

Warning
You’ll also need to link the program against the math library (see example below) using the -lm compile/link option.
RETURN VALUE

The floor function returns a floating point number that contains the largest integer value that is not greater than x.

SEE ALSO

ceil

EXAMPLE
link:src/floor.c[role=include]
OUTPUT
$ gcc -Wall -lm floor.c
$ ./a.out
Enter a floating point number > 45.98
FLOOR(45.980000) = 45.000000
$ ./a.out
Enter a floating point number > -45.98
FLOOR(-45.980000) = -46.000000