From 4f8acf953ccf1a978a3378db7fb1e8d5a7afbca1 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Fri, 30 Nov 2018 21:15:23 +0000 Subject: math: add double precision error handling functions --- src/math/__math_divzero.c | 6 ++++++ src/math/__math_invalid.c | 6 ++++++ src/math/__math_oflow.c | 6 ++++++ src/math/__math_uflow.c | 6 ++++++ src/math/__math_xflow.c | 6 ++++++ 5 files changed, 30 insertions(+) create mode 100644 src/math/__math_divzero.c create mode 100644 src/math/__math_invalid.c create mode 100644 src/math/__math_oflow.c create mode 100644 src/math/__math_uflow.c create mode 100644 src/math/__math_xflow.c (limited to 'src/math') diff --git a/src/math/__math_divzero.c b/src/math/__math_divzero.c new file mode 100644 index 00000000..59d21350 --- /dev/null +++ b/src/math/__math_divzero.c @@ -0,0 +1,6 @@ +#include "libm.h" + +double __math_divzero(uint32_t sign) +{ + return fp_barrier(sign ? -1.0 : 1.0) / 0.0; +} diff --git a/src/math/__math_invalid.c b/src/math/__math_invalid.c new file mode 100644 index 00000000..17740490 --- /dev/null +++ b/src/math/__math_invalid.c @@ -0,0 +1,6 @@ +#include "libm.h" + +double __math_invalid(double x) +{ + return (x - x) / (x - x); +} diff --git a/src/math/__math_oflow.c b/src/math/__math_oflow.c new file mode 100644 index 00000000..c85dbf98 --- /dev/null +++ b/src/math/__math_oflow.c @@ -0,0 +1,6 @@ +#include "libm.h" + +double __math_oflow(uint32_t sign) +{ + return __math_xflow(sign, 0x1p769); +} diff --git a/src/math/__math_uflow.c b/src/math/__math_uflow.c new file mode 100644 index 00000000..b90594ae --- /dev/null +++ b/src/math/__math_uflow.c @@ -0,0 +1,6 @@ +#include "libm.h" + +double __math_uflow(uint32_t sign) +{ + return __math_xflow(sign, 0x1p-767); +} diff --git a/src/math/__math_xflow.c b/src/math/__math_xflow.c new file mode 100644 index 00000000..744203c4 --- /dev/null +++ b/src/math/__math_xflow.c @@ -0,0 +1,6 @@ +#include "libm.h" + +double __math_xflow(uint32_t sign, double y) +{ + return eval_as_double(fp_barrier(sign ? -y : y) * y); +} -- cgit v1.2.1