/**************************************************************************/
/*                                                                        */
/*                                 Sources                                */
/*                                from  the                               */
/*                           XSC SOFTWARE PACKAGE                         */
/*                                                                        */
/*                Copyright (c) 1997 University of Karlsruhe              */
/*                     Institute for Appl. Mathematics                    */
/*                                                                        */
/* This program is free software for non-commercial use. For details, see */
/* the file LICENSE.XSC, distributed with this software package.          */
/*                                                                        */
/* This program is distributed WITHOUT ANY WARRANTY. For details, see the */
/* file LICENSE.XSC, distributed with this software package.              */
/*                                                                        */
/**************************************************************************/

/* RCS $Id: l_subc.c,v 1.2 1997/09/25 17:39:12 ae59 Exp $ */
/*
$Log: l_subc.c,v $
 * Revision 1.2  1997/09/25  17:39:12  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:23:30  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : l_subc.c                              */
/*                                                              */
/*      Entries         : multiprecision l_subc(i1,i2)          */
/*                        multiprecision i1,i2;                 */
/*                                                              */
/*      Description     : Subtraction of multi-precision numbers*/
/*                        with chopping.                        */
/*                                                              */
/*      Date            : 1990-11-22                            */
/*      1990-11-22 : E_TPUSH+E_TPOPP                            */
/*      1990-10-30 : temporary flag                             */
/*      1990-08-06 : explicit compare                           */
/*      1990-07-16 : LINT_ARGS prototype                        */
/****************************************************************/

#ifndef ALL_IN_ONE
#ifdef AIX
#include "/u/p88c/runtime/o_defs.h"
#else
#include "o_defs.h"
#endif
#define local
#endif

#ifdef LINT_ARGS
local multiprecision l_subc(multiprecision i1,multiprecision i2)
#else
local multiprecision l_subc(i1,i2)

multiprecision i1;
multiprecision i2;
#endif
        {
        int rc;
        multiprecision res;

        E_TPUSH("l_subc")

        l_init(&res);

        if (res==NULL)
                e_trap(ALLOCATION,2,E_TMSG,65);
        else if ((rc = b_bsub(i1,i2,res))!=0)
                {
                switch(rc)
                   {
                   case OFLOW : e_trap(OVERFLOW,4,E_TMLT+E_TEXT(1),&i1,
                                                  E_TMLT+E_TEXT(2),&i2);
                                break;
                   case UFLOW : e_trap(UNDERFLOW,4,E_TMLT+E_TEXT(1),&i1,
                                                   E_TMLT+E_TEXT(2),&i2);
                                break;
                   case ALLOC : e_trap(ALLOCATION,2,E_TMSG,65);
                                break;
                   }
                }
        else
           res->f = 1;

        if (i1->f) l_free(&i1);
        if (i2->f) l_free(&i2);

        E_TPOPP("l_subc")
        return(res);
        }
