cs_calc

Description

Performs an arithmetic operation on two operands.

Syntax

CS_RETCODE cs_calc(context, op, datatype, var1,
              var2, dest)
 
 CS_CONTEXT      *context;
 CS_INT                 op;
 CS_INT                 datatype;
 CS_VOID              *var1;
 CS_VOID              *var2;
 CS_VOID              *dest;

Parameters

context

A pointer to a CS_CONTEXT structure.

op

One of the following symbolic values:

Value of op

Arithmetic operation

*dest Value on return

CS_ADD

Addition

var1 + var2

CS_SUB

Subtraction

var1 - var2

CS_MULT

Multiplication

var1 * var2

CS_DIV

Division

var1 /var2

datatype

One of the following symbolic values, to indicate the datatype of var1, var2, and dest:

Value of datatype

Indicates this datatype

CS_DECIMAL_TYPE

CS_DECIMAL

CS_MONEY_TYPE

CS_MONEY

CS_MONEY4_TYPE

CS_MONEY4

CS_NUMERIC_TYPE

CS_NUMERIC

*var1, *var2, and *dest must all be the same datatype as indicated by the value of datatype.

var1

A pointer to the first operand for the arithmetic operation.

var2

A pointer to the second operand for the arithmetic operation.

dest

A pointer to a destination buffer. If cs_calc returns CS_FAIL, *dest is not modified.

Returns

cs_calc can return the following values:

Returns

Indicates

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

Common reasons for a cs_calc failure include:

cs_calc generates a CS-Library error message for most failure conditions. For more information on CS-Library error handling, see “Error handling”.

Usage

See also

cs_convert