/**************************************************************************/
/*                                                                        */
/*                                 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: t_dadd.c,v 1.2 1997/09/25 18:09:45 ae59 Exp $ */
/*
$Log: t_dadd.c,v $
 * Revision 1.2  1997/09/25  18:09:45  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:25:09  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : t_dadd.c                              */
/*                                                              */
/*      Date            : 1991-08-05                            */
/*      1991-08-05 : remove unused variables d,marg,eshift,earga*/
/*      1991-06-21 : new routine                                */
/****************************************************************/

#ifdef AIX
#include "/u/p88c/runtime/tbyte/t_ddev.h"
#else
#include "t_ddev.h"
#endif

/*--------------------------------------------------------------*/
/* add DReal arg to DReal res                                   */
/*--------------------------------------------------------------*/
#ifdef ANSI_C
#ifdef LINT_ARGS
int adddd(const DReal *arg1, const DReal *arg2, DReal *res)
#else
int adddd(arg1, arg2, res)
const DReal *arg1;
const DReal *arg2;
      DReal *res;
#endif /* LINT_ARGS */
#else  /* NOT ANSI_C */
#ifdef LINT_ARGS
int adddd(DReal *arg1, DReal *arg2, DReal *res)
#else
int adddd(arg1, arg2, res)
DReal *arg1;
DReal *arg2;
DReal *res;
#endif /* LINT_ARGS */
#endif /* ANSI_C */
{

   /* --- ein arg == 0 --- */
   if(arg1->s==0) {
      copydd(arg2, res);
      return 0;
   }

   if(arg2->s==0) {
      copydd(arg1, res);
      return 0;
   }

   /* --- ein arg < 0 --- */
   if(arg1->s!=arg2->s)
      switch(cmpabsdd(arg1, arg2)) {
      case 1:
         return dsub(arg1, arg2, res);
      case 0:
         return initd(res);
      case -1:
         return dsub(arg2, arg1, res);
      }

   return dadd(arg1, arg2, res);
} /* adddd */

