/**************************************************************************/
/*                                                                        */
/*                                 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_clss.c,v 1.2 1997/09/25 17:43:40 ae59 Exp $ */
/*
$Log: r_clss.c,v $
 * Revision 1.2  1997/09/25  17:43:40  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:23:50  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : r_clss.c                              */
/*                                                              */
/*      Entries         : a_intg r_clss(x)                      */
/*                                                              */
/*      Arguments       : real x;                               */
/*                                                              */
/*      Function value  : E_CLS0 - signaling NaN                */
/*                        E_CLS1 - quiet NaN                    */
/*                        E_CLS2 - -infinity                    */
/*                        E_CLS3 - negative normalized nonzero  */
/*                        E_CLS4 - negative denormalized        */
/*                        E_CLS5 - -0                           */
/*                        E_CLS6 - +0                           */
/*                        E_CLS7 - positive denormalized        */
/*                        E_CLS8 - positive normalized nonzero  */
/*                        E_CLS9 - +infinity                    */
/*                                                              */
/*      Description     : determine the class of an IEEE        */
/*                        coded real value.                     */
/*                                                              */
/*      Date            : 1991-04-23                            */
/*      1991-04-23 : MANT_INFINITY() used                       */
/*      1991-01-07 : SIGNALING macro introduced                 */
/*      1990-11-19 : 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_intg r_clss(a_real x)
#else
local a_intg r_clss(x)

a_real x;
#endif
        {
        a_btyp mant[D_U_RATIO];
        a_intg expo,res;
        a_bool vz;

        E_TPUSH("r_clss")

        if (b_deko(x,&expo,mant,&vz))
           res = (vz) ? E_CLS5 : E_CLS6;
        else if (expo==EXPO_MAX+1)
           {
           if (MANT_INFINITY(mant))
              res = (vz) ? E_CLS2 : E_CLS9;
           else
              res = (SIGNALING(mant[0])) ? E_CLS0 : E_CLS1;
           }
        else if (expo==EXPO_MIN-1)
           res = (vz) ? E_CLS4 : E_CLS7;
        else
           res = (vz) ? E_CLS3 : E_CLS8;

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