The floating-point engine built into the processor is quite capable of throwing exceptions for float division by zero. Windows has an exception code allocated for it, STATUS_FLOAT_DIVIDE_BY_ZERO, exception code 0xC000008E, "Floating point division by zero." Like other failures that the FPU can report, such as overflow, underflow, and inaccurate results (aka denormals).
Whether this is determined by this control register, programs can change this register using an auxiliary function such as _ controlfp () . Libraries created using Borland tools typically did this, for example by exposing these exceptions.
That didn't work, to say the least. This is the worst possible global variable you can imagine. Mixing such libraries with others that are expecting division by zero to generate infinity instead of an exception simply does not work and is almost impossible to process.
Accordingly, currently the norm for language loops is to mask all floating point exceptions. The CLR insist on this as well.
Working with a library that masks exceptions is complicated, but has a stupid workaround. You can throw an exception and catch it again. The exception handling code inside the CLR resets the control register. An example of this is shown in this answer .
source share