SAND CDBMS Tools Reference Guide
NDL++ Functions:
Syntax and Examples

 

Previous Topic:
String Function Syntax and Examples

Chapter Index
Next Topic:
Custom Library Functions

 

Math Functions Syntax and Examples


This section provides the syntax for, and examples of, each NDL++ math function that can be used in ndlm data load specification scripts. The following considerations apply to the use of NDL++ math functions:

Function Description
ABS(x) Calculates the absolute value of x
ATN(x) Calculates the arctangent of x in radians
COS(x) Calculates the cosine of x in radians
EXP(x) Calculates the exponential of
LOGN(x) Calculates the natural logarithm of x
POW(x,y) Calculates x raised to the power of y
ROUND(x) Rounds x to the decimal point
SIGN(x) Determines the sign of x: returns 1 if x is positive, 1 if x is negative, and 0 if x is zero.
SIN(x) Calculates the sine of x in radians 
SQR(x) Calculates the square root of x
TAN(x) Calculates the tangent of x in radians
TRUNC(x) Truncates x at the decimal point

 

Declaring Numeric Data Types

When a field or column contains a numeric value, the data type can be declared with the function invocation (as in Example 1) or within the TYPE section (as in Example 2).

Example 1:

schema1.table1
{
col1 ABS(INT(field1))
}


Example 2:

TYPE
{
INT field1
FLOAT field2,field3,...
}

 



ABS( )

The ABS() function calculates the absolute value of x.

Syntax:

ABS(x)


Example:

input: -250

IMPORT @sample.dat
{

TYPE
{
INT field1
}
RECORD
{
field1 *\r\n
}
schema1.table1
{
col1 ABS(field1)
}

}


Results:

schema1.table1.col1 250


ATN( )

The ATN() function calculates the arctangent of x in radians.

Syntax:

ATN(x)


Example:

ATN(100) returns 1.560797e-000



COS( )

The COS() function calculates the cosine of x in radians.

Syntax:

COS(x)


Example:

COS(100) returns 8.623189e-001



EXP( )

The EXP() function returns the natural logarithm e raised to the power of x.

Syntax:

EXP(x)  

where the constant value of e is 2.718281828.


Example:

EXP(100) returns 2.688117e+043



LOGN( )

The LOGN() function calculates the natural logarithm of x in radians.

Syntax:

LOGN(x)

Example:

LOGN(120) returns 4.787492e+000




POW( )

The POW() function calculates the value of x raised to the power of y. The function returns an integer if both x and y are integers; otherwise it returns a float value.

Syntax:

POW(x,y)

where x is the base, and y is the exponent.


Example:

POW(10,5) returns 100000




ROUND( )

The ROUND() function rounds x to the decimal point.

Syntax:

ROUND(x)


Example:

ROUND(10.499) returns 10

 



SIGN( )

The SIGN() function returns 1 if x is greater than 0, -1 if x is less than 0, and 0 if x equals 0.

Syntax:

SIGN(x)


Example:

SIGN(-100.676) returns -1




SIN( )

The SIN() function calculates the sine of x in radians.

Syntax:

SIN(x)


Example:

SIN(10) returns -5.440211e-001




SQR( )

The SQR() function calculates the square root of x.

Syntax:

SQR(x)


Example:

SQR(100) returns 10

 



TAN( )

The TAN() function calculates the tangent of x in radians.

Syntax:

TAN(x)


Example:

TAN(100) returns -5.872139e-001

 



TRUNC( )

The TRUNC() function truncates x at the decimal point.

Syntax:

TRUNC(x)


Example:

input: 5.5534770E+002

IMPORT @sample.dat
{

RECORD
{
field1 *\r\n
}
schema1.table1
{
col1 TRUNC(FLOAT(field1))
}

}


Results:

schema1.table1.col1 5.5500000E+002 column declared as float(24)

 


Previous Topic:
String Function Syntax and Examples
Chapter Index
Next Topic:
Custom Library Functions