IBM PureData System for Analytics, Version 7.1

Math functions

The following sections describe the trigonometric, random number, miscellaneous, and binary math functions.

Trigonometric functions

The following table describes the trigonometric functions.
Table 1. Trigonometric functions
Function Input data type Output data type Description
acos(x) double precision double precision Inverse cosine.
asin(x) double precision double precision Inverse sine.
atan(x) double precision double precision Inverse tangent.
atan2(x,y) double precision double precision Inverse tangent of x/y.
cos(x) double precision double precision Cosine.
cot(x) double precision double precision Cotangent.
degrees(x) double precision double precision Convert radians to degrees.
pi() (none) double precision The constant pi.
radians(x) double precision double precision Convert degrees to radians.
sin(x) double precision double precision sine
tan(x) double precision double precision tangent

Random number functions

The following table describes the random number functions.
Table 2. Random number math functions
Function Input data type Output data type Description Example Result
random() (none) double precision Random value greater than 0 and less than 1. random() 0.27116098407244
setseed(x)   (none) Set the seed for the random() function. setseed(0.548) (return code)

Miscellaneous math functions

The following table describes the miscellaneous math functions.
Table 3. Miscellaneous math functions
Function Input data type Output data type Description Example Result
n! byteint, smallint, integer, bigint int8 Factorial of the integer n:
n×(n-1)×...×1
5! 120
abs(x)   same as x Absolute value. abs (-17.4) 17.4
ceil(x) numeric numeric Smallest whole number that is not less than x ceil (-42.8) -42
dceil(x) double precision double precision Smallest whole number that is not less than x dceil (42.8) 43
dfloor(x) double precision double precision Largest integer not greater than argument floor(42.8) 42
exp(x) double precision, numeric same as x Exponential. exp(1.0) 2.71828182845905
floor(x) numeric numeric largest integer not greater than argument floor(-42.8) -43
fpow(a,b) real real a raised to the power of b pow(9.0, 3.0) 729
ln(x) double precision double natural logarithm ln(2.0) 0.693147180559945
log(x) numeric numeric base 10 logarithm log(100.0) 2
mod(x,y) double precision, real, numeric, byteint, smallint, integer, bigint If the type of either x or y is double precision or a real, the output type is double precision; otherwise, if either x or y is numeric, the output is numeric; otherwise, x and y are integers and the output data type is the wider of the two input data types Computes the remainder of x/y mod(9,4) 1
numeric_sqrt(x) numeric numeric square root numeric_sqrt(2) 1.4142
pow(a,b) double precision dp a raised to the power of b pow(9.0, 3.0) 729
round(x) double precision, numeric same as input round to nearest integer round(42.4) 42
round(v,n) v is numeric, n is byteint, smallint, integer, bigint numeric round to s decimal places round(42.4382,2) 42.44
sign(x) numeric numeric sign of the argument(-1,0,+1) sign(-8.4) -1
sqrt(x) double precision double square root sqrt(2.0) 1.4142135623731
trunc(x) double precision, numeric same as input truncate toward zero trunc(42.8) 42
trunc(v,n) v is numeric, n is byteint, smallint, integer, bigint numeric truncate to s decimal places trunc(42.4382,2) 42.43
Note: The result of the pow function must fit in a FLOAT8 (be a double precision floating point value). A FLOAT8 can hold positive or negative values with a magnitude as large as 1.798 x 10308 and as small as 4.941 x 10-324(approximately).

Binary math functions

The following table describes the binary math functions:
Table 4. Binary math functions
Function Description
intNand(x,y) Bitwise AND of x and y.
intNor(x,y) Bitwise OR of x and y.
intNxor(x,y) Bitwise exclusive OR of x and y.
intNnot(x) Bitwise NOT of x.
intNshl(x,y [,z]) Shift left, with optional mask. x is ANDed with z (if present) then shifted left by y bits.
intNshr(x,y [,z]) Shift right, with optional mask. x is ANDed with z (if present) then shifted right by y bits.
In each function, the placeholder N represents the byte size of the integer data type that the function operates on and returns:
1
byteint (alias int1)
2
smallint (alias int2)
4
integer (alias int and int4)
8
bigint (alias int8)


Feedback | Copyright IBM Corporation 2014 | Last updated: 2014-02-28