/**************************************************************************/
/*                                                                        */
/*                                 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_outm.c,v 1.2 1997/09/25 17:05:09 ae59 Exp $ */
/*
$Log: b_outm.c,v $
 * Revision 1.2  1997/09/25  17:05:09  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:21:35  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : b_outm.c                              */
/*                                                              */
/*      Entries         : void b_outm                           */
/*                      (mant,len,expo,digits,buffer,bdp,dexpo) */
/*                        a_intg len,*dexpo,digits,expo,*bdp;   */
/*                        a_btyp *mant;                         */
/*                        char *buffer;                         */
/*                                                              */
/*      Arguments       : mant   - mantissa of intern value     */
/*                        len    - length of mantissa           */
/*                        expo   - exponent of intern value     */
/*                        digits - number of digits             */
/*                        buffer - output string                */
/*                        bdp    - position of decimal point    */
/*                        dexpo  - decimal exponent of first    */
/*                                non-zero digit                */
/*                                dexpo<0 : float format        */
/*                                dexpo>=0: fixed format        */
/*                                                              */
/*      Description     : Decimal representation determined from*/
/*                        exponent and mantissa of multi-       */
/*                        precision value                       */
/*                                                              */
/*      Date            : 1990-11-12                            */
/*      1990-11-12 : E_TPUSH+E_TPOPP                            */
/****************************************************************/

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

#ifdef LINT_ARGS
local void b_outm(a_btyp *mant,a_intg len,a_intg expo,a_intg digits,
                  char *buffer,a_intg *bdp,a_intg *dexpo)
#else
local void b_outm(mant,len,expo,digits,buffer,bdp,dexpo)

a_btyp *mant;
a_intg len;
a_intg expo;
a_intg digits;
char *buffer;
a_intg *bdp;
a_intg *dexpo;
#endif
        {
        a_intg i;

        E_TPUSH("b_outm")

        b_cm__[A_BEGIN] = A_D_P-expo;
        b_cm__[A_END] = (A_D_P+len-1)-expo;

        /* insufficient buffer size                             */
        if (b_cm__[A_END]>A_LENGTH || b_cm__[A_BEGIN]<A_START)
           e_trap(I_O_BUFFER,2,E_TMSG,39);

        /* copy value to I/O-buffer                             */
        for (i=len-1;i>=0;i--)
           b_cm__[A_D_P-expo+i] = mant[i];

        /* clear accu contents between number and decimal point */
        for (i=A_D_P+len-expo;i<=A_D_P;i++)
           b_cm__[i] = ZERO;
        for (i=A_D_P+1;i<=(A_D_P-1)-expo;i++)
           b_cm__[i] = ZERO;

        /* conversion of integer part    */
        if (expo>=0)
           {
           b_outi(&digits,buffer,bdp,dexpo,b_cm__);
           }

        /* conversion of fraction part                          */
        if (digits>0)
           {
           b_outf(&digits,buffer,bdp,dexpo,b_cm__);
           }

        E_TPOPP("b_outm")
        return;
        }
