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

Miscellaneous 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 miscellaneous 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.

copysign

Description: The copysign function returns the value with the magnitude of x and the sign of y.

Calling interface:
double copysign(double x, double y);
long double copysignl(long double x, long double y);
float copysignf(float x, float y);
_Float16 copysignf16(_Float16 x, _Float16 y);

fabs

Description: The fabs function returns the absolute value of x.

Calling interface:
double fabs(double x);
long double fabsl(long double x);
float fabsf(float x);
_Float16 fabsf16(_Float16 x);

fdim

Description: The fdim function returns the positive difference value, x-y (for x > y) or +0 (for x <= to y).

errno: ERANGE, for overflow conditions

Calling interface:
double fdim(double x, double y);
long double fdiml(long double x, long double y);
float fdimf(float x, float y);
_Float16 fdimf16(_Float16 x, _Float16 y);

finite

Description: The finite function returns 1 if x is not a NaN or +/- infinity. Otherwise 0 is returned.

Calling interface:
int finite(double x);
int finitel(long double x);
int finitef(float x);
int finitef16(_Float16 x);

fma

Description: The fma functions return (x*y)+z.

Calling interface:
double fma(double x, double y, double z);
long double fmal(long double x, long double y, long double z);
float fmaf(float x, float y, float z);
_Float16 fmaf16(_Float16 x, _Float16 y, _Float16 z);

fmax

Description: The fmax function returns the maximum numeric value of its arguments.

Calling interface:
double fmax(double x, double y);
long double fmaxl(long double x, long double y);
float fmaxf(float x, float y);
_Float16 fmaxf16(_Float16 x, _Float16 y);

fmin

Description: The fmin function returns the minimum numeric value of its arguments.

Calling interface:
double fmin(double x, double y);
long double fminl(long double x, long double y);
float fminf(float x, float y);
_Float16 fminf16(_Float16 x, _Float16 y);

fpclassify

Description: The fpclassify function returns the value of the number classification macro appropriate to the value of its argument. Possible values are:

  • 0 (NaN)
  • 1 (Infinity)
  • 2 (Zero)
  • 3 (Subnormal)
  • 4 (Finite)

Calling interface:
int fpclassify(double x);
int fpclassifyl(long double x);
int fpclassifyf(float x);
int fpclassifyf16(_Float16 x);

isfinite

Description: The isfinite function returns 1 if x is not a NaN or +/- infinity. Otherwise 0 is returned.

Calling interface:
int isfinite(double x);
int isfinitel(long double x);
int isfinitef(float x);
int isfinitef16(_Float16 x);

isgreater

Description: The isgreater function returns 1 if x is greater than y. This function does not raise the invalid floating-point exception.

Calling interface:
int isgreater(double x, double y);
int isgreaterl(long double x, long double y);
int isgreaterf(float x, float y);
int isgreaterf16(_Float16 x, _Float16 y);

isgreaterequal

Description: The isgreaterequal function returns 1 if x is greater than or equal to y. This function does not raise the invalid floating-point exception.

Calling interface:
int isgreaterequal(double x, double y);
int isgreaterequall(long double x, long double y);
int isgreaterequalf(float x, float y);
int isgreaterequalf16(_Float16 x, _Float16 y);

isinf

Description: The isinf function returns a non-zero value if and only if its argument has an infinite value.

Calling interface:
int isinf(double x);
int isinfl(long double x);
int isinff(float x);
int isinff16(_Float16 x);

isless

Description: The isless function returns 1 if x is less than y. This function does not raise the invalid floating-point exception.

Calling interface:
int isless(double x, double y);
int islessl(long double x, long double y);
int islessf(float x, float y);
int islessf16(_Float16 x, _Float16 y);

islessequal

Description: The islessequal function returns 1 if x is less than or equal to y. This function does not raise the invalid floating-point exception.

Calling interface:
int islessequal(double x, double y);
int islessequall(long double x, long double y);
int islessequalf(float x, float y);
int islessequalf16(_Float16 x, _Float16 y);

islessgreater

Description: The islessgreater function returns 1 if x is less than or greater than y. This function does not raise the invalid floating-point exception.

Calling interface:
int islessgreater(double x, double y);
int islessgreaterl(long double x, long double y);
int islessgreaterf(float x, float y);
int islessgreaterf16(_Float16 x, _Float16 y);

isnan

Description: The isnan function returns a non-zero value, if and only if x has a NaN value.

Calling interface:
int isnan(double x);
int isnanl(long double x);
int isnanf(float x);
int isnanf16(_Float16 x);

isnormal

Description: The isnormal function returns a non-zero value, if and only if x is normal.

Calling interface:
int isnormal(double x);
int isnormall(long double x);
int isnormalf(float x);
int isnormalf16(_Float16 x);

isunordered

Description: The isunordered function returns 1 if either x or y is a NaN. This function does not raise the invalid floating-point exception.

Calling interface:
int isunordered(double x, double y);
int isunorderedl(long double x, long double y);
int isunorderedf(float x, float y);
int isunorderedf16(_Float16 x, _Float16 y);

maxmag

Description: The maxmag function returns the value of larger magnitude from among its two arguments, x and y. If |x| > |y| it returns x; if |y| > |x| it returns y; otherwise it behaves like fmax(x,y).

Calling interface:
double maxmag(double x, double y);
float maxmagf(float x, float y);
_Float16 maxmagf16(_Float16 x, _Float16 y);

minmag

Description: The minmag function returns the value of smaller magnitude from among its two arguments, x and y. If |x| < |y| it returns x; if |y| < |x| it returns y; otherwise it behaves like fmin(x,y).

Calling interface:
double minmag(double x, double y);
float minmagf(float x, float y);
_Float16 maxmagf16(_Float16 x, _Float16 y);

nan

Description: The nan function returns a quiet NaN, with content indicated through tagp.

Calling interface:
double nan(const char *tagp);
long double nanl(const char *tagp);
float nanf(const char *tagp);
_Float16 nanf16(const char *tagp);

nextafter

Description: The nextafter function returns the next representable value in the specified format after x in the direction of y.

errno: ERANGE, for overflow and underflow conditions

Calling interface:
double nextafter(double x, double y);
long double nextafterl(long double x, long double y);
float nextafterf(float x, float y);
_Float16 nextafterf16(_Float16 x, _Float16 y);

nexttoward

Description: The nexttoward function returns the next representable value in the specified format after x in the direction of y. If x equals y, then the function returns y converted to the type of the function. Use the Qlong-double option on Windows operating systems for accurate results.

errno: ERANGE, for overflow and underflow conditions

Calling interface:
double nexttoward(double x, long double y);
long double nexttowardl(long double x, long double y);
float nexttowardf(float x, long double y);
_Float16 nexttowardf16(_Float16 x, long double y);

signbit

Description: The signbit function returns a non-zero value, if and only if the sign of x is negative.

Calling interface:
int signbit(double x);
int signbitl(long double x);
int signbitf(float x);

significand

Description: The significand function returns the significand of x in the interval [1,2). For x equal to zero, NaN, or +/- infinity, the original x is returned.

Calling interface:
double significand(double x);
long double significandl(long double x);
float significandf(float x);
_Float16 significandf16(_Float16 x);