/**************************************************************************/
/*                                                                        */
/*                                 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: r_flot.c,v 1.2 1997/09/25 17:46:31 ae59 Exp $ */
/*
$Log: r_flot.c,v $
 * Revision 1.2  1997/09/25  17:46:31  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:23:59  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : r_flot.c                              */
/*                                                              */
/*      Entries         : a_real r_flot(i)                      */
/*                        a_intg i;                             */
/*                                                              */
/*      Arguments       :                                       */
/*                        i = integer value to be converted     */
/*                                                              */
/*      Description     : Convert integer value to real.        */
/*                                                              */
/*      Date            : 1990-11-19                            */
/*      1990-11-19 : E_TPUSH+E_TPOPP                            */
/*      1990-07-06 : while-loop replaces if construct           */
/****************************************************************/

#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_real r_flot(a_intg i)
#else
local a_real r_flot(i)

a_intg i;
#endif
        {
        a_real m;
        a_btyp mant[D_U_RATIO];
        a_bool vz = FALSE;
        a_intg expo;

        E_TPUSH("r_flot")

        B_CLEAR(mant,D_U_RATIO)

        if (i==0) expo = -CHARAC;
        else
           {
           if (i<0)
              {
              vz = TRUE;
              mant[0] = (i==MININT) ? (a_btyp)i : -i;
              }
           else
              mant[0] = i;

           expo = EXPO_SHIFT;

           /* normalization of mantissa                         */
           if ( SHFT_MASK & mant[0] )
              {
              do
                 {
                 b_shr1(mant,D_U_RATIO);
                 expo++;
                 }
              while (SHFT_MASK & mant[0]);
              }
           else
              {
              while ( (HIDDEN_BIT & mant[0])==ZERO )
                 {
                 mant[0] <<= 1;
                 expo--;
                 }
              }
           }

        b_comp(&m,expo,mant,vz);

        E_TPOPP("r_flot")
        return(m);
        }
