/**************************************************************************/
/*                                                                        */
/*                                 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_comp.c,v 1.2 1997/09/25 17:33:45 ae59 Exp $ */
/*
$Log: l_comp.c,v $
 * Revision 1.2  1997/09/25  17:33:45  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:23:13  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : l_comp.c                              */
/*                                                              */
/*      Entries         : multiprecision l_comp(a,n)            */
/*                        multiprecision a;                     */
/*                        a_intg n;                             */
/*                                                              */
/*      Description     : Generate multiprecision value from    */
/*                        mantissa a and base 2 exponent n.     */
/*                        0.5 <= |a| < 1.0                      */
/*                                                              */
/*      Date            : 1990-11-15                            */
/*      1990-11-15 : E_TPUSH+E_TPOPP / consider temporary flag  */
/****************************************************************/

#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_comp(multiprecision a,a_intg n)
#else
local multiprecision l_comp(a,n)

multiprecision a;
a_intg n;
#endif
        {
        multiprecision res;

        E_TPUSH("l_comp")

        if (a->z==0 && (a->m[0] & MSB)==ZERO)
           e_trap(INV_ARG,2,E_TMLT+E_TEXT(7),&a);

        l_init(&res);

        if (res==NULL)
           e_trap(ALLOCATION,2,E_TMSG,65);
        else
           {
           if (n) n = b_bshf(n,a,res);
           else n = b_bcpy(a,res);

           if (n==ALLOC)
              {
              e_trap(ALLOCATION,2,E_TMSG,65);
              res->z = 1;
              }
           }

        if (a->f) l_free(&a);

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