In the past two days, I used webbrower to write things. Sometimes the "invalid floating point operation." error occurs when I open an SSL encrypted website. I searched the internet and pasted the solution.
Cause
In delphi2011, you must use the floating point unit control command to set the floating point operation unit. The floating point unit control command controls the precision of the floating point operation, the rounding method, and whether a specific floating point operation triggers an exception. For more information, see the Intel processor documentation.
In delphi2011, functions can directly access the control commands of the processor. For example, you can use the set8087cw function to change the value of the 8087cw control command, thus changing the floating point computing behavior of the program. Programmers need to reset the command at the end of the program.
Solution,To directly disable floating point exceptions, use the following method:
In delphi2011, when OpenGL is used for 3D rendering, we recommend that you use the set8087cw function to disable floating point exceptions. You can write set8087cw (0x133f) before calling the OpenGL function, for example, in the oncreate process of mainform)
Instance code:
1. Declare global variables to save the original 8087cw settings
VaR
Saved8087cw: word;
2. Change the value of 8087cw in the oncreate process of mainform. Save the default value before changing the value.
Saved8087cw: = default8087cw;
Set8087cw ($ 133f); {disable all FPU exceptions}
3. Before the program ends, use the default value to reset the 8087cw command value. In the onclose process of mainform
Set8087cw (saved8087cw );
4. note that if scenecontrol is used in the program. when loadsxfile loads a 3D file, you must call the clearlayers method of iscene to clear the layer before set8087cw when the program exits. Otherwise, an exception occurs when the program exits.
Reference code:
Scenecontrol1.scene. clearlayers;
Set8087cw (saved8087cw );
5. You also need to call the following statement before exiting the program.
(Coaoinitialize. Create as iaoinitialize). Shutdown