diff --git a/src/c/number.d b/src/c/number.d index 51659c54e..06d1dee4e 100644 --- a/src/c/number.d +++ b/src/c/number.d @@ -916,3 +916,23 @@ _ecl_float_to_integer(float d) return _ecl_big_register_copy(z); } } + +#ifdef ECL_IEEE_FP +cl_object +si_nan() { +#ifdef ECL_LONG_FLOAT + ecl_make_long_float(NAN); +#else + ecl_make_double_float(NAN); +#endif +} + +cl_object +si_infinity() { +#ifdef ECL_LONG_FLOAT + ecl_make_long_float(INFINITY); +#else + ecl_make_double_float(INFINITY); +#endif +} +#endif /* ECL_IEEE_FP */ diff --git a/src/c/symbols_list.h b/src/c/symbols_list.h index 317b08677..81e099a16 100755 --- a/src/c/symbols_list.h +++ b/src/c/symbols_list.h @@ -1901,6 +1901,9 @@ cl_symbols[] = { {EXT_ "*BYTECODES-COMPILER*", EXT_SPECIAL, NULL, -1, ECL_NIL}, #ifdef ECL_IEEE_FP +{SYS_ "NAN", EXT_ORDINARY, si_nan, 0, OBJNULL}, +{SYS_ "INFINITY", EXT_ORDINARY, si_infinity, 0, OBJNULL}, + {EXT_ "SHORT-FLOAT-POSITIVE-INFINITY", EXT_CONSTANT, NULL, -1, OBJNULL}, {EXT_ "SINGLE-FLOAT-POSITIVE-INFINITY", EXT_CONSTANT, NULL, -1, OBJNULL}, {EXT_ "DOUBLE-FLOAT-POSITIVE-INFINITY", EXT_CONSTANT, NULL, -1, OBJNULL}, diff --git a/src/c/symbols_list2.h b/src/c/symbols_list2.h index 310a3dced..8c90e3b1c 100644 --- a/src/c/symbols_list2.h +++ b/src/c/symbols_list2.h @@ -1901,6 +1901,9 @@ cl_symbols[] = { {EXT_ "*BYTECODES-COMPILER*",NULL}, #ifdef ECL_IEEE_FP +{SYS_ "NAN","si_nan"}, +{SYS_ "INFINITY","si_infinity"}, + {EXT_ "SHORT-FLOAT-POSITIVE-INFINITY",NULL}, {EXT_ "SINGLE-FLOAT-POSITIVE-INFINITY",NULL}, {EXT_ "DOUBLE-FLOAT-POSITIVE-INFINITY",NULL}, diff --git a/src/doc/new-doc/standards/index.txi b/src/doc/new-doc/standards/index.txi index 6860d3c1c..e33e6b6a0 100644 --- a/src/doc/new-doc/standards/index.txi +++ b/src/doc/new-doc/standards/index.txi @@ -61,7 +61,9 @@ @node Numbers @section Numbers @c build option --with-ieee-fp={yes|no} - +@c si::trap-fpe +@c si::nan +@c si::infinity @c ext:{short,single,double,long}-float-{positive,negative}-infinity @c ext:float-nan-p @c ext:float-infinity-p diff --git a/src/h/external.h b/src/h/external.h index 64aea9cdd..285b06d36 100755 --- a/src/h/external.h +++ b/src/h/external.h @@ -1117,6 +1117,10 @@ extern ECL_API double ecl_to_double(cl_object x); extern ECL_API long double ecl_to_long_double(cl_object x); extern ECL_API cl_object ecl_make_long_float(long double f); #endif +#ifdef ECL_IEEE_FP +extern cl_object si_nan(); +extern cl_object si_infinity(); +#endif /* ECL_IEEE_FP */ /* num_co.c */ diff --git a/src/lsp/numlib.lsp b/src/lsp/numlib.lsp index 8cb4e86ad..b96e20cf4 100644 --- a/src/lsp/numlib.lsp +++ b/src/lsp/numlib.lsp @@ -74,22 +74,15 @@ )) #+ieee-floating-point -(locally - (declare (notinline -)) - (let* ((bits (si::trap-fpe 'last nil))) - (let ((a (/ (coerce 1 'short-float) (coerce 0.0 'short-float)))) - (defconstant short-float-positive-infinity a) - (defconstant short-float-negative-infinity (- a))) - (let ((a (/ (coerce 1 'single-float) (coerce 0.0 'single-float)))) - (defconstant single-float-positive-infinity a) - (defconstant single-float-negative-infinity (- a))) - (let ((a (/ (coerce 1 'double-float) (coerce 0.0 'double-float)))) - (defconstant double-float-positive-infinity a) - (defconstant double-float-negative-infinity (- a))) - (let ((a (/ (coerce 1 'long-float) (coerce 0.0 'long-float)))) - (defconstant long-float-positive-infinity a) - (defconstant long-float-negative-infinity (- a))) - (si::trap-fpe bits t))) +(let ((inf (si::infinity))) + (defconstant short-float-positive-infinity (coerce inf 'short-float)) + (defconstant short-float-negative-infinity (coerce (- inf) 'short-float)) + (defconstant single-float-positive-infinity (coerce inf 'single-float)) + (defconstant single-float-negative-infinity (coerce (- inf) 'single-float)) + (defconstant double-float-positive-infinity (coerce inf 'double-float)) + (defconstant double-float-negative-infinity (coerce (- inf) 'double-float)) + (defconstant long-float-positive-infinity (coerce inf 'long-float)) + (defconstant long-float-negative-infinity (coerce (- inf) 'long-float))) (defconstant imag-one #C(0.0 1.0))