Home Explore Blog CI



postgresql

96th chunk of `doc/src/sgml/ecpg.sgml`
04e913c1ff9cf3ca3ae6531848345ec2aa7116474fbe51d50000000100000fa1
 <term><function>deccvdbl</function></term>
      <listitem>
       <para>
        Convert a value of type double to a value of type decimal.
<synopsis>
int deccvdbl(double dbl, decimal *np);
</synopsis>
        The function receives the variable of type double that should be
        converted as its first argument (<literal>dbl</literal>). As the second
        argument (<literal>np</literal>), the function receives a pointer to the
        decimal variable that should hold the result of the operation.
       </para>
       <para>
        The function returns 0 on success and a negative value if the
        conversion failed.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-functions-deccvint">
      <term><function>deccvint</function></term>
      <listitem>
       <para>
        Convert a value of type int to a value of type decimal.
<synopsis>
int deccvint(int in, decimal *np);
</synopsis>
        The function receives the variable of type int that should be
        converted as its first argument (<literal>in</literal>). As the second
        argument (<literal>np</literal>), the function receives a pointer to the
        decimal variable that should hold the result of the operation.
       </para>
       <para>
        The function returns 0 on success and a negative value if the
        conversion failed.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-functions-deccvlong">
      <term><function>deccvlong</function></term>
      <listitem>
       <para>
        Convert a value of type long to a value of type decimal.
<synopsis>
int deccvlong(long lng, decimal *np);
</synopsis>
        The function receives the variable of type long that should be
        converted as its first argument (<literal>lng</literal>). As the second
        argument (<literal>np</literal>), the function receives a pointer to the
        decimal variable that should hold the result of the operation.
       </para>
       <para>
        The function returns 0 on success and a negative value if the
        conversion failed.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-functions-decdiv">
      <term><function>decdiv</function></term>
      <listitem>
       <para>
        Divide two variables of type decimal.
<synopsis>
int decdiv(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 division fails.
        If overflow or underflow occurred, the function returns
        <literal>ECPG_INFORMIX_NUM_OVERFLOW</literal> or
        <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

Title: Informix Decimal Conversion and Arithmetic Functions (deccvdbl, deccvint, deccvlong, decdiv, decmul)
Summary
This section describes several Informix-compatible functions for decimal manipulation. It details `deccvdbl` (convert double to decimal), `deccvint` (convert int to decimal), `deccvlong` (convert long to decimal), `decdiv` (divide two decimals), and `decmul` (multiply two decimals), including their synopsis, parameters, return values, and potential error codes (e.g., overflow, underflow, division by zero).