/**************************************************************************/
/*                                                                        */
/*                                 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_gt.c,v 1.2 1997/09/25 17:47:08 ae59 Exp $ */
/*
$Log: r_gt.c,v $
 * Revision 1.2  1997/09/25  17:47:08  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:24:01  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : r_gt.c                                */
/*                                                              */
/*      Entries         : a_bool r_gt(a,b)                      */
/*                        a_real a,b;                           */
/*                                                              */
/*      Arguments       : a = IEEE operand                      */
/*                        b = IEEE operand                      */
/*                                                              */
/*      Function value  : TRUE if a>b                           */
/*                        FALSE if a<=b                         */
/*                                                              */
/*      Description     : compare IEEE values                   */
/*                                                              */
/*      Note            : FALSE returned in case of error       */
/*                                                              */
/*      Date            : 1991-05-02                            */
/*      1991-05-02 : use status flags                           */
/*      1991-04-23 : MANT_INFINITY() used                       */
/*      1991-04-09 : E_TMSG added                               */
/*      1990-11-19 : E_TPUSH+E_TPOPP                            */
/*      1990-11-12 : INV_OP                                     */
/****************************************************************/

#ifndef ALL_IN_ONE
#ifdef AIX
#include "/u/p88c/runtime/o_defs.h"
#else
#include "o_defs.h"
#endif
#define local
extern a_bool e_efio;
extern a_bool e_ofio;
#endif

#ifdef LINT_ARGS
local a_bool r_gt(a_real a,a_real b)
#else
local a_bool r_gt(a,b)

a_real a;
a_real b;
#endif
        {
        a_intg expoa,expob,i;
        a_bool res = FALSE,vza,vzb,zeroa,zerob;
        a_btyp manta[D_U_RATIO];
        a_btyp mantb[D_U_RATIO];

        E_TPUSH("r_gt")

        zeroa = b_deko(a,&expoa,manta,&vza);
        zerob = b_deko(b,&expob,mantb,&vzb);

        if (expoa>=EXPO_MAX+1 || expob>=EXPO_MAX+1)
           {
           if (expoa==EXPO_MAX+1 && MANT_INFINITY(manta))
              {
              if (expob==EXPO_MAX+1)
                 {
                 if (MANT_INFINITY(mantb))
                    res = (NOT(vza) && vza!=vzb) ? TRUE : FALSE;
                 else
                    {
                    res = FALSE;
                    if (e_efio)
                       e_trap(INV_OP+E_IEEE,6,E_TMSG,5,
                                              E_TDBL+E_TEXT(1),&a,
                                              E_TDBL+E_TEXT(2),&b);
                    else
                       e_ofio = TRUE;
                    }
                 }
              else res = NOT(vza);
              }
           else if (expob==EXPO_MAX+1 && MANT_INFINITY(mantb))
              {
              if (expoa!=EXPO_MAX+1) res = vzb;
              else
                 {
                 res = FALSE;
                 if (e_efio)
                    e_trap(INV_OP+E_IEEE,6,E_TMSG,5,
                                           E_TDBL+E_TEXT(1),&a,
                                           E_TDBL+E_TEXT(2),&b);
                 else
                    e_ofio = TRUE;
                 }
              }
           else
              {
              res = FALSE;
              if (e_efio)
                 e_trap(INV_OP+E_IEEE,6,E_TMSG,5,
                                        E_TDBL+E_TEXT(1),&a,
                                        E_TDBL+E_TEXT(1),&b);
              else
                 e_ofio = TRUE;
              }
           }
        else if (zeroa) res = (zerob) ? FALSE : vzb;
        else if (zerob) res = NOT(vza);
        else if (vza!=vzb) res = vzb;
        else if (expoa<expob) res = vza;
        else if (expoa>expob) res = NOT(vza);
        else
           {
           for (i=0;i<D_U_RATIO;i++)
              if (manta[i]<mantb[i]) { res = vza; break; }
              else if (manta[i]>mantb[i]) { res = NOT(vza); break; }
           if (i==D_U_RATIO) res = FALSE;
           }

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