RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Dealing with Floating-point Exceptions in MSVC7\8

Learn how to catch floating-point exceptions in C\C++ code.

ecause the scientific and engineering numeric floating-point calculation approximates real arithmetic, the precision of this format can create situations wherein your floating-point operations results are not acceptable in some domains. A programming error can create some pretty sticky exceptional situations, but this is also a byproduct of the nature of the domain itself. You can find a numerous discussions on different software implementation techniques for dealing with arithmetic floating-point exceptions. Some solutions are slower, others are faster. Some of them prevent occurrences of exceptions, other respond to exceptions.

This article is the result of a study on how to take advantage of what is available in Microsoft's implementation of C\C++ in VS2003 and VS2005 for the latest x86-based platform that supports IEEE Standard 754 for Binary Floating-Point Arithmetic.

You'll learn how to:

  • Enable the floating-point exceptions of your interest.
  • Trap them.
  • Set the Visual Studio compiler options.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date