/**************************************************************************/
/*                                                                        */
/*                                 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: divtrap.h,v 1.2 1997/09/25 16:43:27 ae59 Exp $ */
/*
$Log: divtrap.h,v $
 * Revision 1.2  1997/09/25  16:43:27  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:22:12  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : divtrap.h                             */
/*                                                              */
/*      Description     : NaN or infinity operator in division  */
/*                                                              */
/*      Date            : 1991-04-23                            */
/*      1991-04-23 : MANT_INFINITY() used                       */
/*      1991-04-22 : real assignment replaced by R_ASSIGN()     */
/*      1991-01-07 : SIGNALING macro introduced                 */
/*                   union q removed                            */
/*      1990-11-16 : E_TPUSH+E_TPOPP                            */
/*      1990-11-12 : INV_OP                                     */
/****************************************************************/

                /* a = infinity or NaN                          */
                if (expoa==EXPO_MAX+1) {

                   /* a = infinity                              */
                   if (MANT_INFINITY(manta)) {

                      /* b = infinity or NaN                    */
                      if (expob==EXPO_MAX+1) {

                         /* a = infinity b = NaN                */
                         if (!MANT_INFINITY(mantb)) {
                            if (SIGNALING(mantb[0]))
                               {
                               e_trap(INV_OP+E_IEEE,8,E_TMSG,5,
                                         E_TDBL+E_TEXT(1),&a,
                                         E_TDBL+E_TEXT(2),&b,
                                         E_TDBL+E_TRES,&b);
                               }
                            E_TPOPP("divtrap")
                            return(b);
                            }

                         /* a = b = infinity                    */
                         e_trap(INV_OP+E_IEEE,8,E_TMSG,4,
                                   E_TDBL+E_TEXT(1),&a,
                                   E_TDBL+E_TEXT(2),&b,
                                   E_TDBL+E_TRES,&a);
                         E_TPOPP("divtrap")
                         return(a);
                         }

                      /* infinity divided by number             */
                      if (vza!=vzc) b_comp(&a,expoa,manta,vzc);
                      E_TPOPP("divtrap")
                      return(a);
                      }

                   /* a = NaN                                   */
                   else {
                      if (SIGNALING(manta[0]))
                         {
                         e_trap(INV_OP+E_IEEE,8,E_TMSG,5,
                                   E_TDBL+E_TEXT(1),&a,
                                   E_TDBL+E_TEXT(2),&b,E_TDBL+E_TRES,&a);
                         }
                      else if (expob==EXPO_MAX+1 && SIGNALING(mantb[0]))
                         {
                         e_trap(INV_OP+E_IEEE,8,E_TMSG,5,
                                   E_TDBL+E_TEXT(1),&a,
                                   E_TDBL+E_TEXT(2),&b,E_TDBL+E_TRES,&b);
                         }
                      E_TPOPP("divtrap")
                      return(a);
                      }
                   }

                /* b = infinity or NaN                          */
                else {

                   /* b = infinity                              */
                   if (MANT_INFINITY(mantb))
                      {
                      /* Generate +/- zero                      */
                      R_ASSIGN(a,((vzc) ? *r_sero : *r_zero));
                      E_TPOPP("divtrap")
                      return(a);
                      }

                   /* b = NaN                                   */
                   if (SIGNALING(mantb[0]))
                      {
                      e_trap(INV_OP+E_IEEE,8,E_TMSG,5,
                                E_TDBL+E_TEXT(1),&a,
                                E_TDBL+E_TEXT(2),&b,E_TDBL+E_TRES,&b);
                      }
                   E_TPOPP("divtrap")
                   return(b);
                   }
                }
