4 ms·
On Linux, fpenableexcept(3) lets you do this.
by jmalicki 3y ago
On Linux, fpenableexcept(3) lets you do this.
- kragen 3y agoaha! feenableexcept! i'd never heard of it! // Demonstrate C99/glibc 2.2+ feenableexcept #define _GNU_SOURCE #include <math.h> #include <fenv.h> #include <stdlib.h> #include <stdio.h> int main(int argc, char **argv) { if (argc != 3) { fprintf(stderr, "Usage: %s a b # floating-point divide a by b\n", argv[0]); return 1; } feenableexcept(FE_DIVBYZERO); double a = atof(argv[1]), b = atof(argv[2]); printf("%g ÷ %g = %g\n", a, b, a/b); return 0; } is the machine still ieee-754-compliant after you call feenableexcept? i'm guessing that if it weren't, intel wouldn't have defined the architecture to have this capability, given the historically close relationship between 8087 and ieee-754
- pclmulqdq 3y agoSee my other comment, but it's still compliant. You are allowed to handle exceptions in a lot of different ways.