summaryrefslogtreecommitdiff
path: root/docs/probe_math_exception.c
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2017-06-23 23:56:56 +0200
committerWaldemar Brodkorb <wbx@openadk.org>2017-06-23 23:57:01 +0200
commitdc7ad97385c940c0a0d67b924c1b78159da5549d (patch)
tree8a2aeab9793e9bf101e8e328e73f6765ff853eec /docs/probe_math_exception.c
parent041cdc2769407c4d3869b218ad7ee7638e1c306e (diff)
docs: cleanup directory, fix some porting information
Diffstat (limited to 'docs/probe_math_exception.c')
-rw-r--r--docs/probe_math_exception.c64
1 files changed, 0 insertions, 64 deletions
diff --git a/docs/probe_math_exception.c b/docs/probe_math_exception.c
deleted file mode 100644
index dbc9020d4..000000000
--- a/docs/probe_math_exception.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Small test program for probing how various math functions
- * with specific operands set floating point exceptions
- */
-
-#define _ISOC99_SOURCE 1
-#define _GNU_SOURCE 1
-
-#include <stdint.h>
-#include <math.h>
-#include <fenv.h>
-#include <stdio.h>
-
-int main(int argc, char **argv)
-{
- float largest, small, t, inf_float;
-
- largest = small = 1;
- while (1) {
- t = largest + small;
- /* optimizations may make plain "t == largest" unreliable */
- if (memcmp(&t, &largest, sizeof(float)) == 0)
- break;
- if (isfinite(t)) {
- largest = t;
- small *= 2;
- continue;
- }
- small /= 2;
- }
- inf_float = largest + largest;
- //printf("%.40g ", largest);
- //printf("[%llx]\n", (long long) (*(uint32_t *)&largest));
-
- feclearexcept(FE_ALL_EXCEPT);
-
- //t = 1.0 / 0.0; // simple test: FE_DIVBYZERO
- //t = nextafterf(largest, 1); // glibc 2.8: no math exceptions raised
- //t = nextafterf(largest, largest); // glibc 2.8: no math exceptions raised
- //t = nextafterf(largest, inf_float); // glibc 2.8: FE_INEXACT FE_OVERFLOW
-
-#define PREX(ex) do { if (fetestexcept(ex)) printf(#ex " "); } while(0)
-#ifdef FE_INEXACT
- PREX(FE_INEXACT);
-#endif
-#ifdef FE_DIVBYZERO
- PREX(FE_DIVBYZERO);
-#endif
-#ifdef FE_UNDERFLOW
- PREX(FE_UNDERFLOW);
-#endif
-#ifdef FE_OVERFLOW
- PREX(FE_OVERFLOW);
-#endif
-#ifdef FE_INVALID
- PREX(FE_INVALID);
-#endif
- if (fetestexcept(FE_ALL_EXCEPT))
- printf("\n");
- else
- printf("no math exceptions raised\n");
-
- printf("%.40g\n", t);
- return 0;
-}