diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2009-02-08 02:04:26 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2009-02-08 02:04:26 +0000 |
commit | 9676f11d513a43b0c1640b62b1978136c117d581 (patch) | |
tree | 6c13b57a4a200b5623e15b94e7aa0297eb563f84 /docs/probe_math_exception.c | |
parent | 6015bcfbbbb458ff42b2cee520ad965ad000bb73 (diff) | |
download | uClibc-alpine-9676f11d513a43b0c1640b62b1978136c117d581.tar.bz2 uClibc-alpine-9676f11d513a43b0c1640b62b1978136c117d581.tar.xz |
nextafterf: trying to correct FP exception handling
Diffstat (limited to 'docs/probe_math_exception.c')
-rw-r--r-- | docs/probe_math_exception.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/docs/probe_math_exception.c b/docs/probe_math_exception.c new file mode 100644 index 000000000..dbeccc5cc --- /dev/null +++ b/docs/probe_math_exception.c @@ -0,0 +1,41 @@ +/* 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 <math.h> +#include <fenv.h> +#include <stdio.h> + +int main(int argc, char **argv) +{ + float infF = HUGE_VALF * 2; + + feclearexcept(FE_ALL_EXCEPT); + +// printf("%.40e\n", 1.0 / 0.0); // FE_DIVBYZERO +// printf("%.40e\n", nextafterf(HUGE_VALF, infF)); // no exceptions in glibc 2.4 + +#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"); + printf("done\n"); + return 0; +} |