Performs an arithmetic operation on two operands.
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;
A pointer to a CS_CONTEXT structure.
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 |
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.
A pointer to the first operand for the arithmetic operation.
A pointer to the second operand for the arithmetic operation.
A pointer to a destination buffer. If cs_calc returns CS_FAIL, *dest is not modified.
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:
An invalid parameter
Attempted division by 0
Destination overflow
cs_calc generates a CS-Library error message for most failure conditions. See “Error handling”.
var1, var2, and dest must have the same datatype, as indicated by the datatype parameter.
In case of error, *dest is not modified.