Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

floor(3)  —  Subroutines

NAME

floor, ceil, modf, rint, nint,  trunc − Rounds floating-point numbers to floating-point integers, returns the nearest integral value, and truncates a floating-point number

LIBRARY

Math Library (libm.a)

SYNOPSIS

#include <math.h>

double floor   (double x);
float  floorf  (float  x);
double ceil    (double x);
float  ceilf   (float  x);
double modf    (double x, double ∗n);
float  modff   (float  x, float  ∗n);
double nint    (double x);
float  nintf   (float  x);
double rint    (double x);
float  rintf   (float  x);
double trunc   (double x);
float  truncf  (float  x);

DESCRIPTION

floor() and floorf() return the largest floating-point integer value less than or equal to  x. 

ceil() and ceilf() return the smallest floating-point integer value greater than or equal to  x. 

modf() and modff() split a floating-point number x into a fractional part f and an integer part i such that |f| < 1.0 and (f + i) = x.  Both f and i have the same sign as x.  modf() and modff() return f and store i into the location pointed to by n. 

nint() and nintf() return the nearest integral value to x, except halfway cases are rounded to the integral value larger in magnitude. This corresponds to the Fortran generic intrinsic function nint(). 

rint() and rintf() round x to an integral value according to the current IEEE rounding direction specified by the user. 

trunc() and truncf() truncate x to an integral value. 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026