diff options
author | B. Watson <urchlay@slackware.uk> | 2024-01-04 16:54:45 -0500 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-01-04 16:54:45 -0500 |
commit | 4f3447eba56896aaba1962be3aa2a1ce4081bf0a (patch) | |
tree | db01b8e2de27c2e35832be4ad4554804bb265408 | |
parent | 1982b8ef05ecf839a82792866c21219feb8fa7cc (diff) | |
download | hcalc-4f3447eba56896aaba1962be3aa2a1ce4081bf0a.tar.gz |
Show "err" on FP error, wait for CLR key.
-rw-r--r-- | input.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -10,11 +10,13 @@ #include <string.h> #include <stdlib.h> #include <unistd.h> +#include <fenv.h> char pending_op = 0; int making_number = 0; int base = 10; int quiet = 0; +int showing_err = 0; #define MAXIN 40 @@ -79,6 +81,12 @@ show_value() char commas[40], *cp, *dp; double v = value; + if(fetestexcept(FE_ALL_EXCEPT)) { + set_string("Err"); + showing_err = 1; + return; + } + if (base == 2) { int q = (long long)v & 0xffffffffL; @@ -226,10 +234,16 @@ key(char c) int v = c; /* printf("key_number 0x%x\n", v); */ + feclearexcept(FE_ALL_EXCEPT); + + if(showing_err && c != 27 && c != 'C') + return; + switch (c) { case 27: case 'C': + showing_err = 0; making_number = 0; iptr = 0; pending_op = 0; |