/*
* Copyright 1996 1995 by Open Software Foundation, Inc.
* All Rights Reserved
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notice appears in all copies and
* that both the copyright notice and this permission notice appear in
* supporting documentation.
*
* OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
* NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* pmk1.1
*/
/*
* (c) Copyright 1986 HEWLETT-PACKARD COMPANY
*
* To anyone who acknowledges that this file is provided "AS IS"
* without any express or implied warranty:
* permission to use, copy, modify, and distribute this file
* for any purpose is hereby granted without fee, provided that
* the above copyright notice and this notice appears in all
* copies, and that the name of Hewlett-Packard Company not be
* used in advertising or publicity pertaining to distribution
* of the software without specific, written prior permission.
* Hewlett-Packard Company makes no representations about the
* suitability of this software for any purpose.
*/
/*
* Some more constants
*/
#define SGL_FX_MAX_EXP 30
#define DBL_FX_MAX_EXP 62
#define QUAD_FX_MAX_EXP 126
#define Find_ms_one_bit(value, position) \
{ \
int var; \
for (var=8; var >=1; var >>= 1) { \
if (value >> (32 - position)) \
position -= var; \
else position += var; \
} \
if ((value >> (32 - position)) == 0) \
position--; \
else position -= 2; \
}
/*
* The following 4 functions handle the assignment of a floating point
* number to a 32-bit integer in cases where the floating point number
* is too large (or small) to fit in the integer field.
*
* In all these cases, HP-UX would return an UNIMPLEMENTEDEXCEPTION
* resulting in a SIGFPE being sent to the process. For BSD's math
* library (and various other applications), this was unacceptable.
* As a result, we now return maxint/minint (like most other OS's)
* and either return an INEXACTEXCEPTION (SIGFPE) or set the inexact
* flag (so that the program may continue execution).
*
* After discussing this with Jerry Huck @ HP, the one case where we
* differ from BSD is for programs that try to convert a NaN to an
* integer; in this case, we will return an UNIMPLEMENTEDEXCEPTION
* since doing anything else would be completely unreasonable.
*
* jef
*/
int sgl_to_sgl_fcnvfx(sgl_floating_point *, sgl_floating_point *, unsigned int *);
int sgl_to_dbl_fcnvfx(sgl_floating_point *, dbl_integer *, unsigned int *);
int dbl_to_sgl_fcnvfx(dbl_floating_point *, int *, unsigned int *);
int dbl_to_dbl_fcnvfx(dbl_floating_point *, dbl_integer *, unsigned int *);
int sgl_to_sgl_fcnvfxt(sgl_floating_point *, int *, unsigned int *);
int sgl_to_dbl_fcnvfxt(sgl_floating_point *, dbl_integer *, unsigned int *);
int dbl_to_sgl_fcnvfxt(dbl_floating_point *, int *, unsigned int *);
int dbl_to_dbl_fcnvfxt(dbl_floating_point *, dbl_integer *, unsigned int *);
int sgl_to_sgl_fcnvxf(int *, sgl_floating_point *, unsigned int *);
int sgl_to_dbl_fcnvxf(int *, dbl_floating_point *, unsigned int *);
int dbl_to_sgl_fcnvxf(dbl_integer *, sgl_floating_point *, unsigned int *);
int dbl_to_dbl_fcnvxf(dbl_integer *, dbl_floating_point *, unsigned int *);