/**************************************************************************/
/*                                                                        */
/*                                 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_expo.c,v 1.2 1997/09/25 17:35:25 ae59 Exp $ */
/*
$Log: l_expo.c,v $
 * Revision 1.2  1997/09/25  17:35:25  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:23:18  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : l_expo.c                              */
/*                                                              */
/*      Entries         : a_intg l_expo(a)                      */
/*                        multiprecision a;                     */
/*                                                              */
/*      Description     : Base 2 exponent of factor of most     */
/*                        significant bit of multiprecision     */
/*                        value immediately preceding the       */
/*                        decimal point.                        */
/*                                                              */
/*      Note            : 0 returned if argument is 0.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 a_intg l_expo(multiprecision a)
#else
local a_intg l_expo(a)

multiprecision a;
#endif
        {
        a_intg res;
        a_btyp m;

        E_TPUSH("l_expo")

        if (a->z) res = 0;
        else
           {
           res = B_LENGTH*(a->e+1)-1;
           m = a->m[0];
           while ((m & MSB)==ZERO)
              {
              res--;
              m <<=1;
              }
           }

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

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