12.Integer Mathematical Functions

This section describes integer mathematical functions.

To use these functions, you do not need to include any additional header file in your program.

Functions

__device__ long intabs(long int a)

Calculate the absolute value of the inputlongint argument.

__device__ intabs(int a)

Calculate the absolute value of the inputint argument.

__device__ long long intabs(long long int a)

Calculate the absolute value of the inputlonglongint argument.

__device__ long intlabs(long int a)

Calculate the absolute value of the inputlongint argument.

__device__ long long intllabs(long long int a)

Calculate the absolute value of the inputlonglongint argument.

__device__ long long intllmax(const long long int a, const long long int b)

Calculate the maximum value of the inputlonglongint arguments.

__device__ long long intllmin(const long long int a, const long long int b)

Calculate the minimum value of the inputlonglongint arguments.

__device__ unsigned long intmax(const long int a, const unsigned long int b)

Calculate the maximum value of the inputlongint andunsignedlongint arguments.

__device__ unsigned long long intmax(const unsigned long long int a, const unsigned long long int b)

Calculate the maximum value of the inputunsignedlonglongint arguments.

__device__ unsigned intmax(const unsigned int a, const int b)

Calculate the maximum value of the inputunsignedint andint arguments.

__device__ unsigned long long intmax(const long long int a, const unsigned long long int b)

Calculate the maximum value of the inputlonglongint andunsignedlonglongint arguments.

__device__ unsigned long intmax(const unsigned long int a, const unsigned long int b)

Calculate the maximum value of the inputunsignedlongint arguments.

__device__ long long intmax(const long long int a, const long long int b)

Calculate the maximum value of the inputlonglongint arguments.

__device__ unsigned long long intmax(const unsigned long long int a, const long long int b)

Calculate the maximum value of the inputunsignedlonglongint andlonglongint arguments.

__device__ unsigned long intmax(const unsigned long int a, const long int b)

Calculate the maximum value of the inputunsignedlongint andlongint arguments.

__device__ long intmax(const long int a, const long int b)

Calculate the maximum value of the inputlongint arguments.

__device__ intmax(const int a, const int b)

Calculate the maximum value of the inputint arguments.

__device__ unsigned intmax(const unsigned int a, const unsigned int b)

Calculate the maximum value of the inputunsignedint arguments.

__device__ unsigned intmax(const int a, const unsigned int b)

Calculate the maximum value of the inputint andunsignedint arguments.

__device__ unsigned long intmin(const long int a, const unsigned long int b)

Calculate the minimum value of the inputlongint andunsignedlongint arguments.

__device__ unsigned long long intmin(const unsigned long long int a, const unsigned long long int b)

Calculate the minimum value of the inputunsignedlonglongint arguments.

__device__ unsigned long long intmin(const unsigned long long int a, const long long int b)

Calculate the minimum value of the inputunsignedlonglongint andlonglongint arguments.

__device__ intmin(const int a, const int b)

Calculate the minimum value of the inputint arguments.

__device__ unsigned intmin(const unsigned int a, const int b)

Calculate the minimum value of the inputunsignedint andint arguments.

__device__ unsigned long long intmin(const long long int a, const unsigned long long int b)

Calculate the minimum value of the inputlonglongint andunsignedlonglongint arguments.

__device__ long long intmin(const long long int a, const long long int b)

Calculate the minimum value of the inputlonglongint arguments.

__device__ unsigned intmin(const int a, const unsigned int b)

Calculate the minimum value of the inputint andunsignedint arguments.

__device__ long intmin(const long int a, const long int b)

Calculate the minimum value of the inputlongint arguments.

__device__ unsigned intmin(const unsigned int a, const unsigned int b)

Calculate the minimum value of the inputunsignedint arguments.

__device__ unsigned long intmin(const unsigned long int a, const long int b)

Calculate the minimum value of the inputunsignedlongint andlongint arguments.

__device__ unsigned long intmin(const unsigned long int a, const unsigned long int b)

Calculate the minimum value of the inputunsignedlongint arguments.

__device__ unsigned long long intullmax(const unsigned long long int a, const unsigned long long int b)

Calculate the maximum value of the inputunsignedlonglongint arguments.

__device__ unsigned long long intullmin(const unsigned long long int a, const unsigned long long int b)

Calculate the minimum value of the inputunsignedlonglongint arguments.

__device__ unsigned intumax(const unsigned int a, const unsigned int b)

Calculate the maximum value of the inputunsignedint arguments.

__device__ unsigned intumin(const unsigned int a, const unsigned int b)

Calculate the minimum value of the inputunsignedint arguments.

12.1.Functions

__device__longintabs(longinta)

Calculate the absolute value of the inputlongint argument.

Calculate the absolute value of the input argumenta.

Returns

Returns the absolute value of the input argument.

  • abs(LONG_MIN) isUndefined

__device__intabs(inta)

Calculate the absolute value of the inputint argument.

Calculate the absolute value of the input argumenta.

Returns

Returns the absolute value of the input argument.

  • abs(INT_MIN) isUndefined

__device__longlongintabs(longlonginta)

Calculate the absolute value of the inputlonglongint argument.

Calculate the absolute value of the input argumenta.

Returns

Returns the absolute value of the input argument.

  • abs(LLONG_MIN) isUndefined

__device__longintlabs(longinta)

Calculate the absolute value of the inputlongint argument.

Calculate the absolute value of the input argumenta.

Returns

Returns the absolute value of the input argument.

  • labs(LONG_MIN) isUndefined

__device__longlongintllabs(longlonginta)

Calculate the absolute value of the inputlonglongint argument.

Calculate the absolute value of the input argumenta.

Returns

Returns the absolute value of the input argument.

  • llabs(LLONG_MIN) isUndefined

__device__longlongintllmax(constlonglonginta,constlonglongintb)

Calculate the maximum value of the inputlonglongint arguments.

Calculate the maximum value of the argumentsa andb.

__device__longlongintllmin(constlonglonginta,constlonglongintb)

Calculate the minimum value of the inputlonglongint arguments.

Calculate the minimum value of the argumentsa andb.

__device__unsignedlongintmax(constlonginta,constunsignedlongintb)

Calculate the maximum value of the inputlongint andunsignedlongint arguments.

Calculate the maximum value of the argumentsa andb, perform integer promotion first.

__device__unsignedlonglongintmax(constunsignedlonglonginta,constunsignedlonglongintb)

Calculate the maximum value of the inputunsignedlonglongint arguments.

Calculate the maximum value of the argumentsa andb.

__device__unsignedintmax(constunsignedinta,constintb)

Calculate the maximum value of the inputunsignedint andint arguments.

Calculate the maximum value of the argumentsa andb, perform integer promotion first.

__device__unsignedlonglongintmax(constlonglonginta,constunsignedlonglongintb)

Calculate the maximum value of the inputlonglongint andunsignedlonglongint arguments.

Calculate the maximum value of the argumentsa andb, perform integer promotion first.

__device__unsignedlongintmax(constunsignedlonginta,constunsignedlongintb)

Calculate the maximum value of the inputunsignedlongint arguments.

Calculate the maximum value of the argumentsa andb.

__device__longlongintmax(constlonglonginta,constlonglongintb)

Calculate the maximum value of the inputlonglongint arguments.

Calculate the maximum value of the argumentsa andb.

__device__unsignedlonglongintmax(constunsignedlonglonginta,constlonglongintb)

Calculate the maximum value of the inputunsignedlonglongint andlonglongint arguments.

Calculate the maximum value of the argumentsa andb, perform integer promotion first.

__device__unsignedlongintmax(constunsignedlonginta,constlongintb)

Calculate the maximum value of the inputunsignedlongint andlongint arguments.

Calculate the maximum value of the argumentsa andb, perform integer promotion first.

__device__longintmax(constlonginta,constlongintb)

Calculate the maximum value of the inputlongint arguments.

Calculate the maximum value of the argumentsa andb.

__device__intmax(constinta,constintb)

Calculate the maximum value of the inputint arguments.

Calculate the maximum value of the argumentsa andb.

__device__unsignedintmax(constunsignedinta,constunsignedintb)

Calculate the maximum value of the inputunsignedint arguments.

Calculate the maximum value of the argumentsa andb.

__device__unsignedintmax(constinta,constunsignedintb)

Calculate the maximum value of the inputint andunsignedint arguments.

Calculate the maximum value of the argumentsa andb, perform integer promotion first.

__device__unsignedlongintmin(constlonginta,constunsignedlongintb)

Calculate the minimum value of the inputlongint andunsignedlongint arguments.

Calculate the minimum value of the argumentsa andb, perform integer promotion first.

__device__unsignedlonglongintmin(constunsignedlonglonginta,constunsignedlonglongintb)

Calculate the minimum value of the inputunsignedlonglongint arguments.

Calculate the minimum value of the argumentsa andb.

__device__unsignedlonglongintmin(constunsignedlonglonginta,constlonglongintb)

Calculate the minimum value of the inputunsignedlonglongint andlonglongint arguments.

Calculate the minimum value of the argumentsa andb, perform integer promotion first.

__device__intmin(constinta,constintb)

Calculate the minimum value of the inputint arguments.

Calculate the minimum value of the argumentsa andb.

__device__unsignedintmin(constunsignedinta,constintb)

Calculate the minimum value of the inputunsignedint andint arguments.

Calculate the minimum value of the argumentsa andb, perform integer promotion first.

__device__unsignedlonglongintmin(constlonglonginta,constunsignedlonglongintb)

Calculate the minimum value of the inputlonglongint andunsignedlonglongint arguments.

Calculate the minimum value of the argumentsa andb, perform integer promotion first.

__device__longlongintmin(constlonglonginta,constlonglongintb)

Calculate the minimum value of the inputlonglongint arguments.

Calculate the minimum value of the argumentsa andb.

__device__unsignedintmin(constinta,constunsignedintb)

Calculate the minimum value of the inputint andunsignedint arguments.

Calculate the minimum value of the argumentsa andb, perform integer promotion first.

__device__longintmin(constlonginta,constlongintb)

Calculate the minimum value of the inputlongint arguments.

Calculate the minimum value of the argumentsa andb.

__device__unsignedintmin(constunsignedinta,constunsignedintb)

Calculate the minimum value of the inputunsignedint arguments.

Calculate the minimum value of the argumentsa andb.

__device__unsignedlongintmin(constunsignedlonginta,constlongintb)

Calculate the minimum value of the inputunsignedlongint andlongint arguments.

Calculate the minimum value of the argumentsa andb, perform integer promotion first.

__device__unsignedlongintmin(constunsignedlonginta,constunsignedlongintb)

Calculate the minimum value of the inputunsignedlongint arguments.

Calculate the minimum value of the argumentsa andb.

__device__unsignedlonglongintullmax(constunsignedlonglonginta,constunsignedlonglongintb)

Calculate the maximum value of the inputunsignedlonglongint arguments.

Calculate the maximum value of the argumentsa andb.

__device__unsignedlonglongintullmin(constunsignedlonglonginta,constunsignedlonglongintb)

Calculate the minimum value of the inputunsignedlonglongint arguments.

Calculate the minimum value of the argumentsa andb.

__device__unsignedintumax(constunsignedinta,constunsignedintb)

Calculate the maximum value of the inputunsignedint arguments.

Calculate the maximum value of the argumentsa andb.

__device__unsignedintumin(constunsignedinta,constunsignedintb)

Calculate the minimum value of the inputunsignedint arguments.

Calculate the minimum value of the argumentsa andb.