The ifx_int8mul() function

The ifx_int8mul() function multiplies two int8 type values.

Syntax

mint ifx_int8mul(n1, n2, product)
   ifx_int8_t *n1;
   ifx_int8_t *n2;
   ifx_int8_t *product;
n1
A pointer to the int8 structure that contains the first operand.
n2
A pointer to the int8 structure that contains the second operand.
product
A pointer to the int8 structure that contains the product of n1 * n2.

Usage

The product can be the same as either n1 or n2.

Return codes

0
The operation was successful.
-1284
The operation resulted in overflow or underflow.

Example

The file int8mul.ec in the demo directory contains the following sample program.
/*
   * ifx_int8mul.ec *

    The following program multiplies two INT8 numbers and
    displays the result.
*/

#include <stdio.h>

EXEC SQL include "int8.h";

char string1[] = "480,999,777,666,345";
char string2[] = "80";
char result[41];

main()
{
    mint x;
    ifx_int8_t num1, num2, prd;

    printf("IFX_INT8MUL Sample ESQL Program running.\n\n");

    if (x = ifx_int8cvasc(string1, strlen(string1), &num1))
        {
        printf("Error %d in converting string1 to INT8\n", x);
        exit(1);
        }
    if (x = ifx_int8cvasc(string2, strlen(string2), &num2))
        {
        printf("Error %d in converting string2 to INT8\n", x);
        exit(1);
        }
    if (x = ifx_int8mul(&num1, &num2, &prd))
        {
        printf("Error %d in multiplying num1 by num2\n", x);
        exit(1);
        }
    if (x = ifx_int8toasc(&prd, result, sizeof(result)))
        {
        printf("Error %d in converting product to string\n", x);
        exit(1);
        }
    result[40] = '\0';
    printf("\t%s * %s = %s\n", string1, string2, result);

    printf("\nIFX_INT8MUL Sample Program over.\n\n");
    exit(0);
}

Output

IFX_INT8MUL Sample ESQL Program running.

   480,999,777,666,345 * 80 = 38479982213307600

IFX_INT8MUL Sample Program over.