@@ -71,6 +71,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7171 static Cvar::Cvar<bool > common_floatExceptions_overflow (" common.floatExceptions.overflow" ,
7272 " enable floating point exception for operation producing an overflow" ,
7373 Cvar::INIT, false );
74+ static Cvar::Cvar<bool > common_floatExceptions_test (" common.floatExceptions.test" ,
75+ " test floating point exceptions" ,
76+ Cvar::INIT, false );
7477#endif
7578
7679namespace Sys {
@@ -436,6 +439,28 @@ static void SetFloatingPointExceptions()
436439 unsigned int current;
437440 _controlfp_s (¤t, exceptions, _MCW_EM);
438441 #endif
442+
443+ if (common_floatExceptions_test.Get ())
444+ {
445+ {
446+ volatile float f = -1 .0f ;
447+ Log::Warn (" Testing of INVALID floating point exception." );
448+ Log::Warn (" Computing √%.0f…" , static_cast <float >(f));
449+ Log::Warn (" Result of √%.0f: %.0f" , static_cast <float >(f), sqrt (f));
450+ }
451+ {
452+ volatile float f = 0 .0f ;
453+ Log::Warn (" Testing of DIVBYZERO floating point exception." );
454+ Log::Warn (" Computing 1÷%.0f…" , static_cast <float >(f));
455+ Log::Warn (" Result of 1÷%.0f: %.0f" , static_cast <float >(f), 1 /f);
456+ }
457+ {
458+ volatile float f = std::numeric_limits<float >::max ();
459+ Log::Warn (" Testing of OVERFLOW floating point exception." );
460+ Log::Warn (" Computing 2×%.0f…" , static_cast <float >(f));
461+ Log::Warn (" Result of 2×%.0f: %.0f" , static_cast <float >(f), 2 *f);
462+ }
463+ }
439464#endif
440465}
441466
0 commit comments