/**************************************************************************/
/*                                                                        */
/*                                 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_flor.c,v 1.2 1997/09/25 17:46:21 ae59 Exp $ */
/*
$Log: r_flor.c,v $
 * Revision 1.2  1997/09/25  17:46:21  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:23:59  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : r_flor.c                              */
/*                                                              */
/*      Entries         : a_real r_flor(r)                      */
/*                        a_real r;                             */
/*                                                              */
/*      Arguments       :                                       */
/*                        r = real value                        */
/*                                                              */
/*      Description     : Returns largest integer not greater   */
/*                        than input value.                     */
/*                                                              */
/*      Date            : 1991-04-22                            */
/*      1991-04-22 : real assignment replaced by R_ASSIGN()     */
/*      1991-01-07 : SIGNALING macro introduced                 */
/*      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
#endif

#ifdef LINT_ARGS
local a_real r_flor(a_real r)
#else
local a_real r_flor(r)

a_real r;
#endif
        {
        a_btyp mant[2*D_U_RATIO];
        a_bool vz = FALSE;
        a_intg expo;

        E_TPUSH("r_flor")

        B_CLEAR(mant,2*D_U_RATIO)
        if (b_deko(r,&expo,mant,&vz))
           {
           }
        else if (expo>=EXPO_MAX)
           {
           if (SIGNALING(mant[0]))
              e_trap(INV_OP+E_IEEE,6,E_TMSG,5,E_TDBL+E_TEXT(7),&r,
                     E_TDBL|E_TRES,&r);
           }

        /* number is an integer */
        else if (expo<MANTL-1)
           {
           if (expo>=0)
              {
              b_shru(mant,2*D_U_RATIO,(MANTL-1)-expo);
              b_shlu(mant,D_U_RATIO,(MANTL-1)-expo);
              }
           else
              {
              B_CLEAR(mant,D_U_RATIO)
              expo = -CHARAC;
              }

           b_comp(&r,expo,mant,vz);

           if (vz && NOT(b_test(D_U_RATIO,&mant[D_U_RATIO])))
              R_ASSIGN(r,r_pred(r));
           }

        E_TPOPP("r_flor")
        return(r);
        }
