/**************************************************************************/
/*                                                                        */
/*                                 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_comp.c,v 1.2 1997/09/25 17:00:55 ae59 Exp $ */
/*
$Log: b_comp.c,v $
 * Revision 1.2  1997/09/25  17:00:55  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:21:17  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : b_comp.c                              */
/*                                                              */
/*      Entries         : void b_comp(x,expo,mant,vz)           */
/*                        a_real *x;                            */
/*                        a_intg expo;                          */
/*                        a_btyp *mant;                         */
/*                        a_bool vz;                            */
/*                                                              */
/*      Arguments       : x     - IEEE double format real       */
/*                        expo  - base 2 exponent               */
/*                        mant  - mantissa bits (a_btyp[2])     */
/*                        vz    - sign of number                */
/*                                                              */
/*      Description     : Composition of an IEEE double value   */
/*                        x from exponent, mantissa and sign    */
/*                                                              */
/*      Date            : 1991-07-01                            */
/*      1991-07-01 : NO! swap words within a_btyp for VAX_VMS_C */
/*      1990-11-09 : swap words within a_btyp for VAX_VMS_C     */
/*      1990-09-03 : exponent of denormalized number adjusted   */
/*      1990-07-16 : LINT_ARGS prototype                        */
/****************************************************************/

#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 void b_comp(a_real *x,a_intg expo,a_btyp *mant,a_bool  vz)
#else
local void b_comp(x,expo,mant,vz)

a_real     *x;
a_intg   expo;
a_btyp *mant;
a_bool  vz;
#endif
        {
        a_btyp *u;
#if C_P_3
#else
        size_t i;
#endif

        u = (a_btyp *)x;

        /* copy mantissa                                        */
#if C_P_3
        u[B_HPART] = mant[0]; u[B_LPART] = mant[1];
#else
        for (i=0;i<D_U_RATIO;i++)
            u[B_HPART-((B_HPART-B_LPART)/(D_U_RATIO-1))*i] = mant[i];
#endif

        /* denormalized number                                  */
        if (expo==EXPO_MIN && (mant[0] & HIDDEN_BIT)==ZERO)
           expo = -CHARAC;

        /* normalized number                                    */
        else
           u[B_HPART] &= NOT_HIDDEN_BIT;

        u[B_HPART] |= ((a_btyp)(expo+CHARAC))<<EXPO_SHIFT;

        /* generate sign                                        */
        if (vz)
           u[B_HPART] |= MSB;

        return;
        }

