Name

round

Synopsis

Rounds a floating-point number to an integer value

#include <math.h>
doubleround( double x );
float roundf( float x );
long double roundl( long double x );

The round() functions round a floating-point number to the nearest integer value, regardless of the current rounding direction setting in the floating-point environment. If the argument is exactly halfway between two integers, round() rounds it away from 0. The return value is the rounded integer value.

Example

See the example for nearbyint() in this chapter.

Get C in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.