Number Theory

SQL Math provides a range of arithmitic functions for SQL Server.  Although the main set are here, some advanced arithmatic are provided thoughout SQL Math, such as the Special Functions.

Integer Theory

Function Parameters Description
IsEven Int number Is the Int even (1 = true, 0 = false)
IsEven64 BigInt number Is the BigInt even (1 = true, 0 = false)
IsOdd Int number Is the Int Odd (1 = true, 0 = false)
IsOdd64 BigInt number Is the BigInt Odd (1 = true, 0 = false)
IsPowerOfTwo Int number Is the Int a perfect power of 2 (1 = true, 0 = false)
IsPowerOfTwo64 BigInt number Is the BitInt a perfect power of 2 (1 = true, 0 = false)
CeilingToPowerOfTwo Int number Find the closest perfect power of two that is larger or equal to the provided Int.
CeilingToPowerOfTwo64 BigInt number Find the closest perfect power of two that is larger or equal to the provided BigInt.
PowerOfTwo Int number Raises 2 to the power of the "number" Int parameter (number between 0 and 31)
PowerOfTwo64 BigInt number Raises 2 to the power of the "number" BigInt parameter (number between 0 and 63)
IsPerfectSquare Int number Find out whether the provided Int integer is a perfect square, i.e. a square of an integer (1 = true, 0 = false)
IsPerfectSquare64 BigInt number Find out whether the provided BigInt integer is a perfect square, i.e. a square of an integer (1 = true, 0 = false)
 

Euclid Functions

Function Parameters Description
GreatestCommonDivisor BigInt a
BigInt b
Returns the greatest common divisor (gcd) of two BigInts.
LeastCommonMultiple BigInt a
BigInt b
Returns the least common multiple (lcm) of two BigInts.

Purchase SQL Math