From e439c8e385c197d9ff75ebd50379bcf72ddd58b8 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Tue, 9 Jan 2024 19:48:50 -0500 Subject: Use fpclassify() rather than fetestexcept() --- input.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/input.c b/input.c index 718b7cd..62ad271 100644 --- a/input.c +++ b/input.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include char pending_op = 0; int making_number = 0; @@ -27,6 +27,10 @@ double value, saved, stored=0; void paste(void); void copy(void); +int number_is_ok(double n) { + return (fpclassify(n) & (FP_ZERO | FP_NORMAL )); +} + void bell(void) { if(!quiet) XBell(display, 0); @@ -81,11 +85,11 @@ show_value() char commas[40], *cp, *dp; double v = value; - if(fetestexcept(FE_ALL_EXCEPT)) { + if(!number_is_ok(value)) { set_string("Err"); bell(); showing_err = 1; - value = 0; /* so it doesn't get saved on exit! */ + saved = value = 0; /* so it doesn't get saved on exit! */ return; } @@ -236,8 +240,6 @@ key(char c) int v = c; /* printf("key_number 0x%x\n", v); */ - feclearexcept(FE_ALL_EXCEPT); - if(showing_err) { switch(c) { /* list the keys that should be still active in error state */ -- cgit v1.2.3