/**************************************************************************/
/*                                                                        */
/*                                 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: b_subm.c,v 1.2 1997/09/25 17:08:06 ae59 Exp $ */
/*
$Log: b_subm.c,v $
 * Revision 1.2  1997/09/25  17:08:06  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:21:45  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : b_subm.c                              */
/*                                                              */
/*      Entry           : a_bool b_subm(k,a,b)                  */
/*                        a_intg k;                             */
/*                        a_btyp *a,*b;                         */
/*                                                              */
/*      Arguments       : a = first operand of subtraction      */
/*                        b = second operand of subtraction     */
/*                        k = size of operands                  */
/*                                                              */
/*      Function value  : TRUE if borrow remains                */
/*                                                              */
/*      Description     : Subtraction of a_btyp arrays          */
/*                        a = a-b                               */
/*                                                              */
/*      Date            : 1990-07-16                            */
/*      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 a_bool b_subm(a_intg k,a_btyp *a,a_btyp *b)
#else
local a_bool b_subm(k,a,b)

a_intg k;
a_btyp *a;
a_btyp *b;
#endif
        {
        a_intg borrow = 0;
        a_btyp c;

        while (--k>=0) {
#if C_P_2
                c = a[k]-b[k]-borrow;
                borrow = (a[k]<b[k] ||
                         (a[k]==b[k] && borrow)) ? 1 : 0;
                a[k] = c;
#else
                b_subu(a[k],b[k],borrow,a+k,&borrow);
#endif
                }

        return((borrow) ? TRUE : FALSE);
        }
