Turning off Floating Point Exceptions in BCB and Delphi

When running floating point code, such as that found in Direct 3D, you will often get a series of floating point exceptions. Microsoft supporesses these exceptions by default, but we raise them. It is easy to turn this option off in both C++Builder and Delphi.

Here is how to turn them off in C++Builder:

#include float.h

__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
  _control87(MCW_EM, MCW_EM);
}

Here is how to turn them off in Delphi:

  const
    MCW_EM = DWord($133f);
  begin
    Set8087CW(MCW_EM);
  end;