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 input
longintargument.- __device__ intabs(int a)
Calculate the absolute value of the input
intargument.- __device__ long long intabs(long long int a)
Calculate the absolute value of the input
longlongintargument.- __device__ long intlabs(long int a)
Calculate the absolute value of the input
longintargument.- __device__ long long intllabs(long long int a)
Calculate the absolute value of the input
longlongintargument.- __device__ long long intllmax(const long long int a, const long long int b)
Calculate the maximum value of the input
longlongintarguments.- __device__ long long intllmin(const long long int a, const long long int b)
Calculate the minimum value of the input
longlongintarguments.- __device__ unsigned long intmax(const long int a, const unsigned long int b)
Calculate the maximum value of the input
longintandunsignedlongintarguments.- __device__ unsigned long long intmax(const unsigned long long int a, const unsigned long long int b)
Calculate the maximum value of the input
unsignedlonglongintarguments.- __device__ unsigned intmax(const unsigned int a, const int b)
Calculate the maximum value of the input
unsignedintandintarguments.- __device__ unsigned long long intmax(const long long int a, const unsigned long long int b)
Calculate the maximum value of the input
longlongintandunsignedlonglongintarguments.- __device__ unsigned long intmax(const unsigned long int a, const unsigned long int b)
Calculate the maximum value of the input
unsignedlongintarguments.- __device__ long long intmax(const long long int a, const long long int b)
Calculate the maximum value of the input
longlongintarguments.- __device__ unsigned long long intmax(const unsigned long long int a, const long long int b)
Calculate the maximum value of the input
unsignedlonglongintandlonglongintarguments.- __device__ unsigned long intmax(const unsigned long int a, const long int b)
Calculate the maximum value of the input
unsignedlongintandlongintarguments.- __device__ long intmax(const long int a, const long int b)
Calculate the maximum value of the input
longintarguments.- __device__ intmax(const int a, const int b)
Calculate the maximum value of the input
intarguments.- __device__ unsigned intmax(const unsigned int a, const unsigned int b)
Calculate the maximum value of the input
unsignedintarguments.- __device__ unsigned intmax(const int a, const unsigned int b)
Calculate the maximum value of the input
intandunsignedintarguments.- __device__ unsigned long intmin(const long int a, const unsigned long int b)
Calculate the minimum value of the input
longintandunsignedlongintarguments.- __device__ unsigned long long intmin(const unsigned long long int a, const unsigned long long int b)
Calculate the minimum value of the input
unsignedlonglongintarguments.- __device__ unsigned long long intmin(const unsigned long long int a, const long long int b)
Calculate the minimum value of the input
unsignedlonglongintandlonglongintarguments.- __device__ intmin(const int a, const int b)
Calculate the minimum value of the input
intarguments.- __device__ unsigned intmin(const unsigned int a, const int b)
Calculate the minimum value of the input
unsignedintandintarguments.- __device__ unsigned long long intmin(const long long int a, const unsigned long long int b)
Calculate the minimum value of the input
longlongintandunsignedlonglongintarguments.- __device__ long long intmin(const long long int a, const long long int b)
Calculate the minimum value of the input
longlongintarguments.- __device__ unsigned intmin(const int a, const unsigned int b)
Calculate the minimum value of the input
intandunsignedintarguments.- __device__ long intmin(const long int a, const long int b)
Calculate the minimum value of the input
longintarguments.- __device__ unsigned intmin(const unsigned int a, const unsigned int b)
Calculate the minimum value of the input
unsignedintarguments.- __device__ unsigned long intmin(const unsigned long int a, const long int b)
Calculate the minimum value of the input
unsignedlongintandlongintarguments.- __device__ unsigned long intmin(const unsigned long int a, const unsigned long int b)
Calculate the minimum value of the input
unsignedlongintarguments.- __device__ unsigned long long intullmax(const unsigned long long int a, const unsigned long long int b)
Calculate the maximum value of the input
unsignedlonglongintarguments.- __device__ unsigned long long intullmin(const unsigned long long int a, const unsigned long long int b)
Calculate the minimum value of the input
unsignedlonglongintarguments.- __device__ unsigned intumax(const unsigned int a, const unsigned int b)
Calculate the maximum value of the input
unsignedintarguments.- __device__ unsigned intumin(const unsigned int a, const unsigned int b)
Calculate the minimum value of the input
unsignedintarguments.
12.1.Functions
- __device__longintabs(longinta)
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__intabs(inta)
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__longlongintabs(longlonginta)
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__longintlabs(longinta)
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__longlongintllabs(longlonginta)
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__longlongintllmax(constlonglonginta,constlonglongintb)
Calculate the maximum value of the input
longlongintarguments.Calculate the maximum value of the arguments
aandb.
- __device__longlongintllmin(constlonglonginta,constlonglongintb)
Calculate the minimum value of the input
longlongintarguments.Calculate the minimum value of the arguments
aandb.
- __device__unsignedlongintmax(constlonginta,constunsignedlongintb)
Calculate the maximum value of the input
longintandunsignedlongintarguments.Calculate the maximum value of the arguments
aandb, perform integer promotion first.
- __device__unsignedlonglongintmax(constunsignedlonglonginta,constunsignedlonglongintb)
Calculate the maximum value of the input
unsignedlonglongintarguments.Calculate the maximum value of the arguments
aandb.
- __device__unsignedintmax(constunsignedinta,constintb)
Calculate the maximum value of the input
unsignedintandintarguments.Calculate the maximum value of the arguments
aandb, perform integer promotion first.
- __device__unsignedlonglongintmax(constlonglonginta,constunsignedlonglongintb)
Calculate the maximum value of the input
longlongintandunsignedlonglongintarguments.Calculate the maximum value of the arguments
aandb, perform integer promotion first.
- __device__unsignedlongintmax(constunsignedlonginta,constunsignedlongintb)
Calculate the maximum value of the input
unsignedlongintarguments.Calculate the maximum value of the arguments
aandb.
- __device__longlongintmax(constlonglonginta,constlonglongintb)
Calculate the maximum value of the input
longlongintarguments.Calculate the maximum value of the arguments
aandb.
- __device__unsignedlonglongintmax(constunsignedlonglonginta,constlonglongintb)
Calculate the maximum value of the input
unsignedlonglongintandlonglongintarguments.Calculate the maximum value of the arguments
aandb, perform integer promotion first.
- __device__unsignedlongintmax(constunsignedlonginta,constlongintb)
Calculate the maximum value of the input
unsignedlongintandlongintarguments.Calculate the maximum value of the arguments
aandb, perform integer promotion first.
- __device__longintmax(constlonginta,constlongintb)
Calculate the maximum value of the input
longintarguments.Calculate the maximum value of the arguments
aandb.
- __device__intmax(constinta,constintb)
Calculate the maximum value of the input
intarguments.Calculate the maximum value of the arguments
aandb.
- __device__unsignedintmax(constunsignedinta,constunsignedintb)
Calculate the maximum value of the input
unsignedintarguments.Calculate the maximum value of the arguments
aandb.
- __device__unsignedintmax(constinta,constunsignedintb)
Calculate the maximum value of the input
intandunsignedintarguments.Calculate the maximum value of the arguments
aandb, perform integer promotion first.
- __device__unsignedlongintmin(constlonginta,constunsignedlongintb)
Calculate the minimum value of the input
longintandunsignedlongintarguments.Calculate the minimum value of the arguments
aandb, perform integer promotion first.
- __device__unsignedlonglongintmin(constunsignedlonglonginta,constunsignedlonglongintb)
Calculate the minimum value of the input
unsignedlonglongintarguments.Calculate the minimum value of the arguments
aandb.
- __device__unsignedlonglongintmin(constunsignedlonglonginta,constlonglongintb)
Calculate the minimum value of the input
unsignedlonglongintandlonglongintarguments.Calculate the minimum value of the arguments
aandb, perform integer promotion first.
- __device__intmin(constinta,constintb)
Calculate the minimum value of the input
intarguments.Calculate the minimum value of the arguments
aandb.
- __device__unsignedintmin(constunsignedinta,constintb)
Calculate the minimum value of the input
unsignedintandintarguments.Calculate the minimum value of the arguments
aandb, perform integer promotion first.
- __device__unsignedlonglongintmin(constlonglonginta,constunsignedlonglongintb)
Calculate the minimum value of the input
longlongintandunsignedlonglongintarguments.Calculate the minimum value of the arguments
aandb, perform integer promotion first.
- __device__longlongintmin(constlonglonginta,constlonglongintb)
Calculate the minimum value of the input
longlongintarguments.Calculate the minimum value of the arguments
aandb.
- __device__unsignedintmin(constinta,constunsignedintb)
Calculate the minimum value of the input
intandunsignedintarguments.Calculate the minimum value of the arguments
aandb, perform integer promotion first.
- __device__longintmin(constlonginta,constlongintb)
Calculate the minimum value of the input
longintarguments.Calculate the minimum value of the arguments
aandb.
- __device__unsignedintmin(constunsignedinta,constunsignedintb)
Calculate the minimum value of the input
unsignedintarguments.Calculate the minimum value of the arguments
aandb.
- __device__unsignedlongintmin(constunsignedlonginta,constlongintb)
Calculate the minimum value of the input
unsignedlongintandlongintarguments.Calculate the minimum value of the arguments
aandb, perform integer promotion first.
- __device__unsignedlongintmin(constunsignedlonginta,constunsignedlongintb)
Calculate the minimum value of the input
unsignedlongintarguments.Calculate the minimum value of the arguments
aandb.
- __device__unsignedlonglongintullmax(constunsignedlonglonginta,constunsignedlonglongintb)
Calculate the maximum value of the input
unsignedlonglongintarguments.Calculate the maximum value of the arguments
aandb.
- __device__unsignedlonglongintullmin(constunsignedlonglonginta,constunsignedlonglongintb)
Calculate the minimum value of the input
unsignedlonglongintarguments.Calculate the minimum value of the arguments
aandb.
- __device__unsignedintumax(constunsignedinta,constunsignedintb)
Calculate the maximum value of the input
unsignedintarguments.Calculate the maximum value of the arguments
aandb.
- __device__unsignedintumin(constunsignedinta,constunsignedintb)
Calculate the minimum value of the input
unsignedintarguments.Calculate the minimum value of the arguments
aandb.