aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 */