Home Explore Blog CI



postgresql

97th chunk of `doc/src/sgml/ecpg.sgml`
ed998ed03767e2a16634e80dc8f586bc23f9b8b9c762e8980000000100000fa0
       <literal>ECPG_INFORMIX_NUM_UNDERFLOW</literal> respectively. If an attempt to
        divide by zero is observed, the function returns
        <literal>ECPG_INFORMIX_DIVIDE_ZERO</literal>.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-functions-decmul">
      <term><function>decmul</function></term>
      <listitem>
       <para>
        Multiply two decimal values.
<synopsis>
int decmul(decimal *n1, decimal *n2, decimal *result);
</synopsis>
        The function receives pointers to the variables that are the first
        (<literal>n1</literal>) and the second (<literal>n2</literal>) operands and
        calculates <literal>n1</literal>*<literal>n2</literal>. <literal>result</literal> is a
        pointer to the variable that should hold the result of the operation.
       </para>
       <para>
        On success, 0 is returned and a negative value if the multiplication
        fails. If overflow or underflow occurred, the function returns
        <literal>ECPG_INFORMIX_NUM_OVERFLOW</literal> or
        <literal>ECPG_INFORMIX_NUM_UNDERFLOW</literal> respectively.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-functions-decsub">
      <term><function>decsub</function></term>
      <listitem>
       <para>
        Subtract one decimal value from another.
<synopsis>
int decsub(decimal *n1, decimal *n2, decimal *result);
</synopsis>
        The function receives pointers to the variables that are the first
        (<literal>n1</literal>) and the second (<literal>n2</literal>) operands and
        calculates <literal>n1</literal>-<literal>n2</literal>. <literal>result</literal> is a
        pointer to the variable that should hold the result of the operation.
       </para>
       <para>
        On success, 0 is returned and a negative value if the subtraction
        fails. If overflow or underflow occurred, the function returns
        <literal>ECPG_INFORMIX_NUM_OVERFLOW</literal> or
        <literal>ECPG_INFORMIX_NUM_UNDERFLOW</literal> respectively.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-functions-dectoasc">
      <term><function>dectoasc</function></term>
      <listitem>
       <para>
        Convert a variable of type decimal to its ASCII representation in a C
        char* string.
<synopsis>
int dectoasc(decimal *np, char *cp, int len, int right)
</synopsis>
        The function receives a pointer to a variable of type decimal
        (<literal>np</literal>) that it converts to its textual representation.
        <literal>cp</literal> is the buffer that should hold the result of the
        operation. The parameter <literal>right</literal> specifies, how many digits
        right of the decimal point should be included in the output. The result
        will be rounded to this number of decimal digits. Setting
        <literal>right</literal> to -1 indicates that all available decimal digits
        should be included in the output. If the length of the output buffer,
        which is indicated by <literal>len</literal> is not sufficient to hold the
        textual representation including the trailing zero byte, only a
        single <literal>*</literal> character is stored in the result and -1 is
        returned.
       </para>
       <para>
        The function returns either -1 if the buffer <literal>cp</literal> was too
        small or <literal>ECPG_INFORMIX_OUT_OF_MEMORY</literal> if memory was
        exhausted.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-functions-dectodbl">
      <term><function>dectodbl</function></term>
      <listitem>
       <para>
        Convert a variable of type decimal to a double.
<synopsis>
int dectodbl(decimal *np, double *dblp);
</synopsis>
        The function receives a pointer to the decimal value to convert
        (<literal>np</literal>) and a pointer to the double variable that
   

Title: Informix Decimal Arithmetic and Conversion Functions (Continued): decmul, decsub, dectoasc, dectodbl
Summary
This section continues describing Informix-compatible decimal functions, focusing on `decmul` (multiply two decimals -revisited due to document cut), `decsub` (subtract two decimals), `dectoasc` (convert decimal to ASCII string with specified precision), and `dectodbl` (convert decimal to double). It details the parameters, return values, and potential error conditions like overflow, underflow, and insufficient buffer size for string conversion.