[Git][cmucl/cmucl][issue-473-make-cr-exp-signal-underflow] Make core-math exp silently return NaN when given NaN
Raymond Toy pushed to branch issue-473-make-cr-exp-signal-underflow at cmucl / cmucl Commits: c84c6c27 by Raymond Toy at 2026-02-16T18:52:48-08:00 Make core-math exp silently return NaN when given NaN This makes exp match what many other core-math routines do with NaN, like log, sin, tan, and sinh, which silently return NaN. This also makes it match what fdlibm does, as mentioned in the comments in e_exp.c. - - - - - 1 changed file: - src/lisp/irrat.c Changes: ===================================== src/lisp/irrat.c ===================================== @@ -197,6 +197,17 @@ double lisp_exp(double x) { #ifdef FEATURE_CORE_MATH + /* + * For consistency, silently return NaN when x is NaN. Do not + * signal an invalid operation, even if invalid operation trap is + * enabled. This is what fdlibm does, and also what many of the + * other core-math routines do. + */ + + if (isnan(x)) { + return x; + } + /* * Can't depend on cr_exp to signal underflow. It seems the * underflow has been constant-folded to zero. Hence, check for View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/c84c6c27bdf205def5c415a2... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/c84c6c27bdf205def5c415a2... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)