2 ms·
I'm pretty sure IEEE 754 covers trapping floating point math. It's not just about in-band signaling. It's unfortunate that the standard is proprietary, so we ca
by fweimer 2y ago
I'm pretty sure IEEE 754 covers trapping floating point math. It's not just about in-band signaling. It's unfortunate that the standard is proprietary, so we can't easily reference it to figure out what it says.
Anyway, most CPUs support a trapping mode, after all. Here's an example with glibc:
#define _GNU_SOURCE
#include <fenv.h>
volatile double x = 1.0;
volatile double y;
volatile double quotient;
int
main(void)
{
feenableexcept(FE_DIVBYZERO);
quotient = x / y;
}
As far as I understand it, overall support for trapping math is poor because not much code is trapping-aware. It would be quite annoying if JSON parsing results in SIGFPE due to an Inexect trap, for example.