/* PFE Extensions: Public types, prototypes, and macros for floating point environment words. Version: 0.5.0 File: fpieee-ext.h Author: David N. Williams License: LGPL Last revision: February 24, 2005 */ /* * Copyright (C) 2005 David N. Williams * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later * version. * * This library is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Library General Public License for more * details. * * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA. * * If you take advantage of the option in the LGPL to put a * particular version of this library under the GPL, the author * would regard it as polite if you would put any direct * modifications under the LGPL as well, and include a copy of * this request near the beginning of the modified library * source. A "direct modification" is one that enhances or * extends the library in line with its original concept, as * opposed to developing a distinct application or library which * might use it. */ #ifndef _PFE_FPIEEE_EXT_H #define _PFE_FPIEEE_EXT_H /****************************************************************/ /* elementary functions new in C99 */ /****************************************************************/ /** F*+ (f: x y z -- y*z+x ) */ extern FCode (p4_f_star_plus); /** FCBRT (f: x -- x^[1/3] ) */ extern FCode (p4_f_cbrt); /** FDIM (f: x y -- x-y | +0 ) */ extern FCode (p4_f_dim); /** FEXP2 (f: x -- 2^x ) */ extern FCode (p4_f_exp2); /** FLOG2 (f: x -- log.base.2[x] ) */ extern FCode (p4_f_log2); /** FERF (f: x -- erf[x] ) */ extern FCode (p4_f_erf); /** FERFC (f: x -- 1-erf[x] ) */ extern FCode (p4_f_erfc); /** FGAMMA (f: x -- gamma[x] ) */ extern FCode (p4_f_gamma); /** FLNGAMMA (f: x -- ln[gamma[x]] ) */ extern FCode (p4_f_ln_gamma); /****************************************************************/ /* floating-point auxiliary functions */ /****************************************************************/ /** FPCLASSIFY (f: x -- s: type ) * Return the appropriate value FP_INFINITE, FP_NAN, FP_NORMAL, * FP_SUBNORMAL, or FP_ZERO provided by the host C99 compiler. * The corresponding Forth constants are FP-INFINITE, etc. */ extern FCode (p4_fpclassify); /** ISFINITE (f: x -- s: flag ) */ extern FCode (p4_isfinite); /** ISINF (f: x -- s: flag ) */ extern FCode (p4_isinf); /** ISNAN (f: x -- s: flag ) */ extern FCode (p4_isnan); /** ISNORMAL (f: x -- s: flag ) */ extern FCode (p4_isnormal); /** COPYSIGN (f: x y -- |x|*sgn[y] ) */ extern FCode (p4_copysign); /** NEXTAFTER (f: x y -- x.next ) * Return the next machine representable number after x in the y * direction. */ extern FCode (p4_nextafter); /** SIGNBIT (f: x -- s: 0|1 ) */ extern FCode (p4_signbit); /** FREXP (f: x -- frac s: n ) * Return the fractional part of x as a floating point number, * frac = 0.0 or 0.5 <= frac < 1.0, and the power n such that * frac*2^n = x. */ extern FCode (p4_frexp); /** LDEXP (f: x s: n -- f: x*2^n ) */ extern FCode (p4_ldexp); /** MODF (f: x -- frac integ ) * Return the integer part of x as a double, and the fractional * part f of x with |f| < 1, both having the same sign as x, so * that x = frac + integ. */ extern FCode (p4_modf); /** MODFD (f: x -- frac s: d ) * A version of MODF that returns the integer part as a * double-cell signed integer. Not in C99. * TENTATIVE! */ extern FCode (p4_modfd); /** SCALBN (f: x s: n -- f: x*b^n ) * The output is efficiently scaled by b^n, with b = FLT_RADIX, * which is also the value of the Forth constant FLT-RADIX. */ extern FCode (p4_scalbn); /** LOGB (f: x -- f: b.exponent ) * Leave the exponent (radix b = FLT_RADIX) of the * floating-point representation. */ extern FCode (p4_logb); /** ILOGB (f: x -- s: b.exponent ) * Leave the exponent (radix b = FLT_RADIX) of the * floating-point representation, with special values: * x exp * 0.0 FP_ILOGB0 * Inf INT_MAX * -Inf INT_MAX * Nan FP_ILOGBNAN * The special output constants are defined elsewhere with Forth * names FP-ILOGB0, FP-ILOGBNAN, INT-MAX. */ extern FCode (p4_ilogb); /****************************************************************/ /* floating-point environment */ /****************************************************************/ /** FE-DEFL-ENV ( -- default.env ) * Leave the default floating-point environment. */ extern P4_CODE (p4_fe_defl_env); /** FEGETENV ( -- fenv ) * Leave the current floating-point environment. */ extern P4_CODE (p4_fegetenv); /** FESETENV ( fenv -- ) * Set the floating-point environment to fenv. */ extern FCode (p4_fesetenv); /** FEHOLDEXCEPT ( -- fenv ) * Leave the current floating-point environment for later * restoration, and install an environment that turns off * floating-point exceptions. */ extern FCode (p4_feholdexcept); /** FEUPDATEENV ( fenv -- ) * Set the floating-point environment to fenv, and raise the * exceptions that were up just before the call. */ extern FCode (p4_feupdateenv); /****************************************************************/ /* floating-point exceptions */ /****************************************************************/ /** FEGETEXCEPTFLAG ( excepts -- fenv ) */ extern FCode (p4_fegetexceptflag); /** FESETEXCEPTFLAG ( fenv excepts -- ) */ extern FCode (p4_fesetexceptflag); /** FETESTEXCEPT ( excepts -- flags ) */ extern FCode (p4_fetestexcept); /** FERAISEEXCEPT ( excepts -- ) */ extern FCode (p4_feraiseexcept); /** FECLEAREXCEPT ( excepts -- ) */ extern FCode (p4_feclearexcept); /****************************************************************/ /* floating-point rounding modes */ /****************************************************************/ /** FEGETROUND ( -- round ) * Leave the current rounding mode value. In C99, negative * means failure. */ extern FCode (p4_fegetround); /** FESETROUND ( round -- failure.flag ) * Set the rounding mode to round. In C99, a return of zero * means success, and a negative value means failure to set. */ extern FCode (p4_fesetround); #endif /* ifndef _PFE_FPIEEE_EXT_H */