/**************************************************************************/
/*                                                                        */
/*                                 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_bmsp.c,v 1.2 1997/09/25 16:59:31 ae59 Exp $ */
/*
$Log: b_bmsp.c,v $
 * Revision 1.2  1997/09/25  16:59:31  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:21:12  ae59
 * Put under RCS control
 *
 */
/************************************************************************/
/*                                                                      */
/* Descriptive Name : b_bmsp.c          Processor : C                   */
/*                                                                      */
/* Subtract product of internal mantissa with unsigned                  */
/* from the result unsigned array.                                      */
/* The internal and the unsigned number must be nonzero.                */
/*                                                                      */
/* Function value : int       - borrow value                            */
/*                                                                      */
/* Function references : b_busp - subtract product of unsigned numbers  */
/*                       b_bcsu - propagate borrow                      */
/*                                                                      */
/*      Date            : 1990-08-02                            */
/*      1990-07-16 : LINT_ARGS prototype                        */
/*      1990-08-02 : result cast (int)                          */
/************************************************************************/

#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 int b_bmsp(a_intg n,a_btyp *i,a_btyp u,a_btyp *r)
#else
local int b_bmsp(n,i,u,r)

a_intg n;               /* length of internal mantissa                  */
a_btyp *i;            /* pointer to intern mantissa of length n       */
a_btyp u;             /* unsigned factor                              */
a_btyp *r;            /* pointer to result mantissa of length n+1     */
#endif
        {
        a_intg borrow = 0; /* borrow value                              */
/*----------------------------------------------------------------------*/
        while (--n>=0)
        if (*(i+n))
        if (b_busp(*(i+n),u,r+n))
        if (b_bcsu(n,r)) borrow = 1;
                        /* subtract product of unsigned factors         */
/*----------------------------------------------------------------------*/
        return((int)borrow);
        }
