/**************************************************************************/
/*                                                                        */
/*                                 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_abs.c,v 1.2 1997/09/25 17:41:27 ae59 Exp $ */
/*
$Log: r_abs.c,v $
 * Revision 1.2  1997/09/25  17:41:27  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:23:44  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : r_abs.c                               */
/*                                                              */
/*      Entries         : a_real r_abs(a)                       */
/*                        a_real a;                             */
/*                                                              */
/*      Arguments       : a = IEEE value                        */
/*                                                              */
/*      Description     : Return positive value of argument.    */
/*                                                              */
/*      Date            : 1992-11-23                            */
/*      1992-11-23 : add E_ieee at e_trap(INV_op ... =b=        */
/*      1991-11-14 : save and restore flags                     */
/*      1991-04-23 : MANT_INFINITY() used / infinity corrected  */
/*      1991-04-22 : r_ass() replaced by b_comp()               */
/*      1990-11-20 : 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
#endif

#ifdef LINT_ARGS
local a_real r_abs(a_real a)
#else
local a_real r_abs(a)

a_real a;
#endif
        {
        a_real res;
        a_intg expoa;
        a_bool vza;
        a_btyp manta[D_U_RATIO];

        E_SPUSH("r_abs")

        if (b_deko(a,&expoa,manta,&vza))
           b_comp(&res,expoa,manta,FALSE);
        else if (expoa>EXPO_MAX)
           {
           if (MANT_INFINITY(manta))
              b_comp(&res,expoa,manta,FALSE);
           else
              {
              if (SIGNALING(manta[0]))
                 e_trap(INV_OP+E_IEEE,2,E_TDBL+E_TEXT(7),&a);
              else
                 e_trap(INV_ARG,2,E_TDBL+E_TEXT(7),&a);
              }
           }
        else
           b_comp(&res,expoa,manta,FALSE);

        E_SPOPP("r_abs")
        return(res);
        }

