aboutsummaryrefslogtreecommitdiffstats
path: root/libj2.h
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2025-12-06 10:21:36 +0100
committerMattias Andrée <m@maandree.se>2025-12-06 10:21:36 +0100
commitc28859c3e10c84fd9f81ebf88336c9b693448eeb (patch)
tree22f9804f4ba96474c23c93c021d293ba5959ccfa /libj2.h
parentSecond commit (diff)
downloadlibj2-c28859c3e10c84fd9f81ebf88336c9b693448eeb.tar.gz
libj2-c28859c3e10c84fd9f81ebf88336c9b693448eeb.tar.bz2
libj2-c28859c3e10c84fd9f81ebf88336c9b693448eeb.tar.xz
Add overflow and underflow prediction functions
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libj2.h')
-rw-r--r--libj2.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/libj2.h b/libj2.h
index aa1747f..4130c97 100644
--- a/libj2.h
+++ b/libj2.h
@@ -52,6 +52,32 @@ struct libj2_j2u {
};
+/**
+ * Arithmetic overflow prediction result
+ *
+ * Use by some functions for which prediction
+ * is costly in edge cases, and thus stopped
+ * as soon as such an edge case is detected
+ */
+enum libj2_overflow {
+ /**
+ * Where will not be an overflow
+ */
+ LIBJ2_NO_OVERFLOW = 0,
+
+ /**
+ * Where will be an overflow
+ */
+ LIBJ2_OVERFLOW = 1,
+
+ /**
+ * Overflow prediction stopped
+ * (due to high cost)
+ */
+ LIBJ2_OVERFLOW_UNKNOWN
+};
+
+
#include "libj2/constants.h"
#include "libj2/signum.h"
#include "libj2/constructors.h"