/**************************************************************************/
/*                                                                        */
/*                                 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: d_gt.c,v 1.2 1997/09/25 17:13:22 ae59 Exp $ */
/*
$Log: d_gt.c,v $
 * Revision 1.2  1997/09/25  17:13:22  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:22:04  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : d_gt.c                                */
/*                                                              */
/*      Entries         : a_bool d_gt(a,b)                      */
/*                        dotprecision a,b;                     */
/*                                                              */
/*      Arguments       : a = dotprecision value                */
/*                        b = dotprecision value                */
/*                                                              */
/*      Function value  : TRUE if a>b                           */
/*                        FALSE if a<=b                         */
/*                                                              */
/*      Description     : Compare dotprecision values           */
/*                                                              */
/*      Date            : 1990-08-09                            */
/*      1990-07-13 : LINT_ARGS prototype                        */
/*      1990-08-02 : accu begin used with cast (int)            */
/*      1990-08-09 : free temporary dotprecision arguments      */
/****************************************************************/

#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_bool d_gt(dotprecision a,dotprecision b)
#else
local a_bool d_gt(a,b)

dotprecision a;
dotprecision b;
#endif
        {
        int i;  /* !!! must be int !!! */
        a_bool res = FALSE;

        if (a[A_BEGIN]==ZERO)
           if (b[A_BEGIN]==ZERO) res = FALSE;
           else res = (b[A_SIGN]) ? TRUE : FALSE;
        else if (b[A_BEGIN]==ZERO)
           res = (a[A_SIGN]) ? FALSE : TRUE;
        else
           {
           if (a[A_SIGN]<b[A_SIGN]) res = TRUE;
           else if (a[A_SIGN]>b[A_SIGN]) res = FALSE;
           else if (a[A_SIGN])
              {
              if (a[A_BEGIN]<b[A_BEGIN]) res = TRUE;
              else if (a[A_BEGIN]>b[A_BEGIN]) res = FALSE;
              else
                 {
                 for (i = (int)a[A_BEGIN];
                      i<=a[A_END] && i<=b[A_END];i++)
                    if (a[i]<b[i]) { res = TRUE; break; }
                    else if (a[i]>b[i]) { res = FALSE; break; }

                 if (i>a[A_END] || i>b[A_END])
                    res = (a[A_END]<b[A_END]) ? TRUE : FALSE;
                 }
              }
           else
              {
              if (a[A_BEGIN]>b[A_BEGIN]) res = TRUE;
              else if (a[A_BEGIN]<b[A_BEGIN]) res = FALSE;
              else
                 {
                 for (i = (int)a[A_BEGIN];
                      i<=a[A_END] && i<=b[A_END];i++)
                     if (a[i]>b[i]) { res = TRUE; break; }
                     else if (a[i]<b[i]) { res = FALSE; break; }

                 if (i>a[A_END] || i>b[A_END])
                    res = (a[A_END]>b[A_END]) ? TRUE : FALSE;
                 }
              }
           }

        if (a[A_STATUS] & A_TEMPORARY) d_free(&a);
        if (b[A_STATUS] & A_TEMPORARY) d_free(&b);

        return(res);
        }
