#ifndef __FP_LOADED #define __FP_LOADED 1 /**************************************************************************** ** ** - ANSI C NCEG floating support ** ***************************************************************************** ** Header defined by NCEG Floating-Point C Extensions WG14/N319 X3J11/94-003 ***************************************************************************** ** ** Copyright 2003 Hewlett-Packard Development Company, L.P. ** ** Confidential computer software. Valid license from HP and/or ** its subsidiaries required for possession, use, or copying. ** ** Consistent with FAR 12.211 and 12.212, Commercial Computer Software, ** Computer Software Documentation, and Technical Data for Commercial ** Items are licensed to the U.S. Government under vendor's standard ** commercial license. ** ** Neither HP nor any of its subsidiaries shall be liable for technical ** or editorial errors or omissions contained herein. The information ** in this document is provided "as is" without warranty of any kind and ** is subject to change without notice. The warranties for HP products ** are set forth in the express limited warranty statements accompanying ** such products. Nothing herein should be construed as constituting an ** additional warranty. ** ***************************************************************************** */ #pragma __nostandard #include #ifdef __cplusplus extern "C" { #endif #if __INITIAL_POINTER_SIZE # pragma __pointer_size __save # pragma __pointer_size 32 #endif /* ** Relaxed refdef external model */ #pragma __extern_model __save #pragma __extern_model __relaxed_refdef /* ** Naturally align all structures */ #pragma __member_alignment __save #pragma __member_alignment /* ** HUGE_VAL is +infinity or double max. Note that D float has 53 bits of ** precision on AXP and 56 on VAX */ #if __G_FLOAT # define HUGE_VAL 8.988465674311578540726371186585e+307 #elif __IEEE_FLOAT # if defined (_IEEE_FP) && (__CRTL_VER >= 60200000) extern double decc$gt_dbl_infinity; # define HUGE_VAL decc$gt_dbl_infinity # else # define HUGE_VAL 1.7976931348623158e+308 # endif #else # if !defined(__VAX) # define HUGE_VAL 1.70141183460469213e+38 # else # define HUGE_VAL 1.70141183460469229e+38 # endif #endif /* ** HUGE_VALL is either +infinity or long double max. */ #if !__X_FLOAT # define HUGE_VALL HUGE_VAL #elif defined (_IEEE_FP) && (__CRTL_VER >= 60200000) extern long double decc$gx_long_dbl_infinity; # define HUGE_VALL decc$gx_long_dbl_infinity #else # define HUGE_VALL 1.189731495357231765085759326628007016196477e4932l #endif /* ** HUGE_VALF is either +infinity or float max for the correct type */ #if __G_FLOAT || __D_FLOAT # define HUGE_VALF 1.7014117e+38f #elif defined (_IEEE_FP) && (__CRTL_VER >= 60200000) extern float decc$gs_float_infinity; # define HUGE_VALF decc$gs_float_infinity #else # define HUGE_VALF 3.40282347e+38f #endif /* ** INFINITY is either +infinity, or a floating constant that overflows at ** compile-time. 1.8e308 is larger than DBL_MAX for D, G or IEEE T. */ #if defined(_IEEE_FP) && (__CRTL_VER >= 60200000) # define INFINITY decc$gt_dbl_infinity #else # define INFINITY 1.8e308 #endif /* ** Implementation's most efficient floating types at least as wide as float ** and double respectively. Both VAX and Alpha AXP are single/double ** architectures and so float and double are efficient types. */ typedef float float_t; typedef double double_t; /* ** NAN is defined to be a quiet NaN, if and only if quiet NaN is supported. */ #ifdef _IEEE_FP extern double decc$gt_dbl_nan; # define NAN decc$gt_dbl_nan #endif /* ** Alpha Only Constants for use with fp_classify ** ** fp_classify is a type-independent macro that uses the classify functions ** in . fp_classify returns one of FP_NAN, FP_INFINIT, FP_NORMAL ** FP_SUBNORMAL or FP_ZERO */ #if !defined(__VAX) # define FP_NAN 0 # define FP_INFINITE 1 # define FP_NORMAL 2 # define FP_SUBNORMAL 3 # define FP_ZERO 4 int fp_classf( float __x ); int fp_class( double __x ); int fp_classl( long double __x ); # define fp_classify(x) ((sizeof(x)==sizeof(float))?fp_classf(x)>>1:(sizeof(x)==sizeof(double))?fp_class(x)>>1:fp_classl(x)>>1) #endif #define __VALH(x) ((unsigned int *)&x)[1] #define __VALL(x) ((unsigned int *)&x)[0] /* ** signbit(x) -- nonzero iff size is negative (negative infinity, zeros and NaN's included) ** isfinite(x) -- nonzero iff x is finite (zero, subnormal or normal) ** isnormal(x) -- nonzero iff x is normal (not zero, subnormal, infinite or Nan) ** isnan(x) -- nonzero iff x is Not-A-Number (NaN) [defined only ** if not previously included */ #if __IEEE_FLOAT # define signbit(x) (__VALH(x) & 0x80000000) # define isfinite(x) ((__VALH(x) & 0x7ff00000) != 0x7ff00000 ) # define isnormal(x) ( ((__VALH(x) & 0x7ff00000) != 0x7ff00000) && ((__VALH(x) & 0x7ff00000) != 0)) ) # if !defined __MATH_LOADED || defined __VAX # define isnan(x) ( ((__VALH(x) & 0x7ff00000) == 0x7ff00000) && ((__VALH(x) & 0xfffff) | __VALL(x)) ) # endif #else # define signbit(x) (__VALL(x) & 0x8000) # define isfinite(x) 1 # define isnormal(x) (x != 0) # if !defined __MATH_LOADED || defined __VAX # define isnan(x) 0 # endif #endif /* ** DECIMAL_DIG -- number of decimal digits such that conversion from double to ** string and back is the identify function if the conversion uses a string of ** DECIMAL_DIG digits. */ #if __D_FLOAT && defined(__VAX) # define DECIMAL_DIG 18 #else # define DECIMAL_DIG 17 #endif /* ** Restore the users pointer context */ #if __INITIAL_POINTER_SIZE # pragma __pointer_size __restore #endif #ifdef __cplusplus } #endif #pragma __member_alignment __restore #pragma __extern_model __restore #pragma __standard #endif /* __FP_LOADED */