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 int abs(long int a)
Calculate the absolute value of the input
longintargument.- __device__ int abs(int a)
Calculate the absolute value of the input
intargument.- __device__ long long int abs(long long int a)
Calculate the absolute value of the input
longlongintargument.- __device__ long int labs(long int a)
Calculate the absolute value of the input
longintargument.- __device__ long long int llabs(long long int a)
Calculate the absolute value of the input
longlongintargument.- __device__ long long int llmax(const long long int a, const long long int b)
Calculate the maximum value of the input
longlongintarguments.- __device__ long long int llmin(const long long int a, const long long int b)
Calculate the minimum value of the input
longlongintarguments.- __device__ unsigned long int max(const long int a, const unsigned long int b)
Calculate the maximum value of the input
longintandunsignedlongintarguments.- __device__ unsigned long long int max(const unsigned long long int a, const unsigned long long int b)
Calculate the maximum value of the input
unsignedlonglongintarguments.- __device__ unsigned int max(const unsigned int a, const int b)
Calculate the maximum value of the input
unsignedintandintarguments.- __device__ unsigned long long int max(const long long int a, const unsigned long long int b)
Calculate the maximum value of the input
longlongintandunsignedlonglongintarguments.- __device__ unsigned long int max(const unsigned long int a, const unsigned long int b)
Calculate the maximum value of the input
unsignedlongintarguments.- __device__ long long int max(const long long int a, const long long int b)
Calculate the maximum value of the input
longlongintarguments.- __device__ unsigned long long int max(const unsigned long long int a, const long long int b)
Calculate the maximum value of the input
unsignedlonglongintandlonglongintarguments.- __device__ unsigned long int max(const unsigned long int a, const long int b)
Calculate the maximum value of the input
unsignedlongintandlongintarguments.- __device__ long int max(const long int a, const long int b)
Calculate the maximum value of the input
longintarguments.- __device__ int max(const int a, const int b)
Calculate the maximum value of the input
intarguments.- __device__ unsigned int max(const unsigned int a, const unsigned int b)
Calculate the maximum value of the input
unsignedintarguments.- __device__ unsigned int max(const int a, const unsigned int b)
Calculate the maximum value of the input
intandunsignedintarguments.- __device__ unsigned long int min(const long int a, const unsigned long int b)
Calculate the minimum value of the input
longintandunsignedlongintarguments.- __device__ unsigned long long int min(const unsigned long long int a, const unsigned long long int b)
Calculate the minimum value of the input
unsignedlonglongintarguments.- __device__ unsigned long long int min(const unsigned long long int a, const long long int b)
Calculate the minimum value of the input
unsignedlonglongintandlonglongintarguments.- __device__ int min(const int a, const int b)
Calculate the minimum value of the input
intarguments.- __device__ unsigned int min(const unsigned int a, const int b)
Calculate the minimum value of the input
unsignedintandintarguments.- __device__ unsigned long long int min(const long long int a, const unsigned long long int b)
Calculate the minimum value of the input
longlongintandunsignedlonglongintarguments.- __device__ long long int min(const long long int a, const long long int b)
Calculate the minimum value of the input
longlongintarguments.- __device__ unsigned int min(const int a, const unsigned int b)
Calculate the minimum value of the input
intandunsignedintarguments.- __device__ long int min(const long int a, const long int b)
Calculate the minimum value of the input
longintarguments.- __device__ unsigned int min(const unsigned int a, const unsigned int b)
Calculate the minimum value of the input
unsignedintarguments.- __device__ unsigned long int min(const unsigned long int a, const long int b)
Calculate the minimum value of the input
unsignedlongintandlongintarguments.- __device__ unsigned long int min(const unsigned long int a, const unsigned long int b)
Calculate the minimum value of the input
unsignedlongintarguments.- __device__ unsigned long long int ullmax(const unsigned long long int a, const unsigned long long int b)
Calculate the maximum value of the input
unsignedlonglongintarguments.- __device__ unsigned long long int ullmin(const unsigned long long int a, const unsigned long long int b)
Calculate the minimum value of the input
unsignedlonglongintarguments.- __device__ unsigned int umax(const unsigned int a, const unsigned int b)
Calculate the maximum value of the input
unsignedintarguments.- __device__ unsigned int umin(const unsigned int a, const unsigned int b)
Calculate the minimum value of the input
unsignedintarguments.
12.1. Functions
-
__device__ long int abs(long int a)
Calculate the absolute value of the input
longintargument.Calculate the absolute value of the input argument
a.- Returns
Returns the absolute value of the input argument.
abs(
LONG_MIN) isUndefined
-
__device__ int abs(int a)
Calculate the absolute value of the input
intargument.Calculate the absolute value of the input argument
a.- Returns
Returns the absolute value of the input argument.
abs(
INT_MIN) isUndefined
-
__device__ long long int abs(long long int a)
Calculate the absolute value of the input
longlongintargument.Calculate the absolute value of the input argument
a.- Returns
Returns the absolute value of the input argument.
abs(
LLONG_MIN) isUndefined
-
__device__ long int labs(long int a)
Calculate the absolute value of the input
longintargument.Calculate the absolute value of the input argument
a.- Returns
Returns the absolute value of the input argument.
labs(
LONG_MIN) isUndefined
-
__device__ long long int llabs(long long int a)
Calculate the absolute value of the input
longlongintargument.Calculate the absolute value of the input argument
a.- Returns
Returns the absolute value of the input argument.
llabs(
LLONG_MIN) isUndefined
-
__device__ long long int llmax(const long long int a, const long long int b)
Calculate the maximum value of the input
longlongintarguments.Calculate the maximum value of the arguments
aandb.
-
__device__ long long int llmin(const long long int a, const long long int b)
Calculate the minimum value of the input
longlongintarguments.Calculate the minimum value of the arguments
aandb.
-
__device__ unsigned long int max(const long int a, const unsigned long int b)
Calculate the maximum value of the input
longintandunsignedlongintarguments.Calculate the maximum value of the arguments
aandb, perform integer promotion first.
-
__device__ unsigned long long int max(const unsigned long long int a, const unsigned long long int b)
Calculate the maximum value of the input
unsignedlonglongintarguments.Calculate the maximum value of the arguments
aandb.
-
__device__ unsigned int max(const unsigned int a, const int b)
Calculate the maximum value of the input
unsignedintandintarguments.Calculate the maximum value of the arguments
aandb, perform integer promotion first.
-
__device__ unsigned long long int max(const long long int a, const unsigned long long int b)
Calculate the maximum value of the input
longlongintandunsignedlonglongintarguments.Calculate the maximum value of the arguments
aandb, perform integer promotion first.
-
__device__ unsigned long int max(const unsigned long int a, const unsigned long int b)
Calculate the maximum value of the input
unsignedlongintarguments.Calculate the maximum value of the arguments
aandb.
-
__device__ long long int max(const long long int a, const long long int b)
Calculate the maximum value of the input
longlongintarguments.Calculate the maximum value of the arguments
aandb.
-
__device__ unsigned long long int max(const unsigned long long int a, const long long int b)
Calculate the maximum value of the input
unsignedlonglongintandlonglongintarguments.Calculate the maximum value of the arguments
aandb, perform integer promotion first.
-
__device__ unsigned long int max(const unsigned long int a, const long int b)
Calculate the maximum value of the input
unsignedlongintandlongintarguments.Calculate the maximum value of the arguments
aandb, perform integer promotion first.
-
__device__ long int max(const long int a, const long int b)
Calculate the maximum value of the input
longintarguments.Calculate the maximum value of the arguments
aandb.
-
__device__ int max(const int a, const int b)
Calculate the maximum value of the input
intarguments.Calculate the maximum value of the arguments
aandb.
-
__device__ unsigned int max(const unsigned int a, const unsigned int b)
Calculate the maximum value of the input
unsignedintarguments.Calculate the maximum value of the arguments
aandb.
-
__device__ unsigned int max(const int a, const unsigned int b)
Calculate the maximum value of the input
intandunsignedintarguments.Calculate the maximum value of the arguments
aandb, perform integer promotion first.
-
__device__ unsigned long int min(const long int a, const unsigned long int b)
Calculate the minimum value of the input
longintandunsignedlongintarguments.Calculate the minimum value of the arguments
aandb, perform integer promotion first.
-
__device__ unsigned long long int min(const unsigned long long int a, const unsigned long long int b)
Calculate the minimum value of the input
unsignedlonglongintarguments.Calculate the minimum value of the arguments
aandb.
-
__device__ unsigned long long int min(const unsigned long long int a, const long long int b)
Calculate the minimum value of the input
unsignedlonglongintandlonglongintarguments.Calculate the minimum value of the arguments
aandb, perform integer promotion first.
-
__device__ int min(const int a, const int b)
Calculate the minimum value of the input
intarguments.Calculate the minimum value of the arguments
aandb.
-
__device__ unsigned int min(const unsigned int a, const int b)
Calculate the minimum value of the input
unsignedintandintarguments.Calculate the minimum value of the arguments
aandb, perform integer promotion first.
-
__device__ unsigned long long int min(const long long int a, const unsigned long long int b)
Calculate the minimum value of the input
longlongintandunsignedlonglongintarguments.Calculate the minimum value of the arguments
aandb, perform integer promotion first.
-
__device__ long long int min(const long long int a, const long long int b)
Calculate the minimum value of the input
longlongintarguments.Calculate the minimum value of the arguments
aandb.
-
__device__ unsigned int min(const int a, const unsigned int b)
Calculate the minimum value of the input
intandunsignedintarguments.Calculate the minimum value of the arguments
aandb, perform integer promotion first.
-
__device__ long int min(const long int a, const long int b)
Calculate the minimum value of the input
longintarguments.Calculate the minimum value of the arguments
aandb.
-
__device__ unsigned int min(const unsigned int a, const unsigned int b)
Calculate the minimum value of the input
unsignedintarguments.Calculate the minimum value of the arguments
aandb.
-
__device__ unsigned long int min(const unsigned long int a, const long int b)
Calculate the minimum value of the input
unsignedlongintandlongintarguments.Calculate the minimum value of the arguments
aandb, perform integer promotion first.
-
__device__ unsigned long int min(const unsigned long int a, const unsigned long int b)
Calculate the minimum value of the input
unsignedlongintarguments.Calculate the minimum value of the arguments
aandb.
-
__device__ unsigned long long int ullmax(const unsigned long long int a, const unsigned long long int b)
Calculate the maximum value of the input
unsignedlonglongintarguments.Calculate the maximum value of the arguments
aandb.
-
__device__ unsigned long long int ullmin(const unsigned long long int a, const unsigned long long int b)
Calculate the minimum value of the input
unsignedlonglongintarguments.Calculate the minimum value of the arguments
aandb.
-
__device__ unsigned int umax(const unsigned int a, const unsigned int b)
Calculate the maximum value of the input
unsignedintarguments.Calculate the maximum value of the arguments
aandb.
-
__device__ unsigned int umin(const unsigned int a, const unsigned int b)
Calculate the minimum value of the input
unsignedintarguments.Calculate the minimum value of the arguments
aandb.