Intel® oneAPI DPC++/C++ Compiler Developer Guide and Reference

ID 767253
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Nearest Integer Functions

Many routines in the Intel® oneAPI DPC++/C++ Compiler Math Library are more optimized for Intel® microprocessors than for non-Intel microprocessors.

The mathimf.h header file includes prototypes for Intel® oneAPI DPC++/C++ Compiler Math Library functions.

The math library supports the following nearest integer functions:

NOTE:

FP16 Math Functions have the following requirements:

  • Version 2021.4 or higher of the Intel® oneAPI DPC++/C++ Compiler.

  • A next-generation Intel® Xeon® Scalable processor, code name Sapphire Rapids.

ceil

Description: The ceil function returns the smallest integral value not less than x as a floating-point number.

Calling interface:
double ceil(double x);
long double ceill(long double x);
float ceilf(float x);
_Float16 ceilf16(_Float16 x);

floor

Description: The floor function returns the largest integral value not greater than x as a floating-point value.

Calling interface:
double floor(double x);
long double floorl(long double x);
float floorf(float x);
_Float16 floorf16(_Float16 x);

llrint

Description: The llrint function returns the rounded integer value (according to the current rounding direction) as a long long int.

errno: ERANGE, for values too large

Calling interface:
long long int llrint(double x);
long long int llrintl(long double x);
long long int llrintf(float x);
long long int llrintf16(_Float16 x);

llround

Description: The llround function returns the rounded integer value as a long long int.

errno: ERANGE, for values too large

Calling interface:
long long int llround(double x);
long long int llroundl(long double x);
long long int llroundf(float x);
long long int llroundf16(_Float16 x);

lrint

Description: The lrint function returns the rounded integer value (according to the current rounding direction) as a long int.

errno: ERANGE, for values too large

Calling interface:
long int lrint(double x);
long int lrintl(long double x);
long int lrintf(float x);
long int lrintf16(_Float16 x);

lround

Description: The lround function returns the rounded integer value as a long int. Halfway cases are rounded away from zero.

errno: ERANGE, for values too large

Calling interface:
long int lround(double x);
long int lroundl(long double x);
long int lroundf(float x);
long int lroundf16(_Float16 x);

modf

Description: The modf function returns the value of the signed fractional part of x and stores the integral part at *iptr as a floating-point number.

Calling interface:
double modf(double x, double *iptr);
long double modfl(long double x, long double *iptr);
float modff(float x, float *iptr);
_Float16 modff16(_Float16 x, _Float16 *iptr);

nearbyint

Description: The nearbyint function returns the rounded integral value as a floating-point number, using the current rounding direction.

Calling interface:
double nearbyint(double x);
long double nearbyintl(long double x);
float nearbyintf(float x);
_Float16 nearbyintf16(_Float16 x);

rint

Description: The rint function returns the rounded integral value as a floating-point number, using the current rounding direction.

Calling interface:
double rint(double x);
long double rintl(long double x);
float rintf(float x);
_Float16 rintf16(_Float16 x);

round

Description: The round function returns the nearest integral value as a floating-point number. Halfway cases are rounded away from zero.

Calling interface:
double round(double x);
long double roundl(long double x);
float roundf(float x);
_Float16 roundf16(_Float16 x);

trunc

Description: The trunc function returns the truncated integral value as a floating-point number.

Calling interface:
double trunc(double x);
long double truncl(long double x);
float truncf(float x);
_Float16 truncf16(_Float16 x);