aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-01-09 19:48:50 -0500
committerB. Watson <urchlay@slackware.uk>2024-01-09 19:48:50 -0500
commite439c8e385c197d9ff75ebd50379bcf72ddd58b8 (patch)
tree920b33fda030a3e598f948a7a2593a4d25d932f9
parent0471c128c1dd6aa1e5e91663854777c4e9859045 (diff)
downloadhcalc-e439c8e385c197d9ff75ebd50379bcf72ddd58b8.tar.gz
Use fpclassify() rather than fetestexcept()
-rw-r--r--input.c12
1 files 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 <string.h>
#include <stdlib.h>
#include <unistd.h>
-#include <fenv.h>
+#include <math.h>
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 */