Alien-FreeImage

 view release on metacpan or  search on metacpan

src/Source/OpenEXR/IexMath/IexMathFloatExc.h  view on Meta::CPAN

//-------------------------------------------------------------

IEXMATH_EXPORT
void mathExcOn (int when = (IEEE_OVERFLOW | IEEE_DIVZERO | IEEE_INVALID));


//----------------------------------------------------------------------
// Function getMathExcOn() tells you for which floating point exceptions
// trapping and conversion to C++ exceptions is currently enabled.
//----------------------------------------------------------------------

IEXMATH_EXPORT
int getMathExcOn();


//------------------------------------------------------------------------
// A classs that temporarily sets floating point exception trapping
// and conversion, and later restores the previous settings.
//
// Example:
//
//	float
//	trickyComputation (float x)
//	{
//	    MathExcOn meo (0);		// temporarily disable floating
//	    				// point exception trapping
//
//	    float result = ...;		// computation which may cause
//	    				// floating point exceptions
//
//	    return result;		// destruction of meo restores
//	}				// the program's previous floating
//					// point exception settings
//------------------------------------------------------------------------

class IEXMATH_EXPORT MathExcOn
{
  public:

    MathExcOn (int when)
	:
	_changed (false)
    {
	_saved = getMathExcOn(); 

	if (_saved != when)
	{
	    _changed = true;
	    mathExcOn (when);
	}
    }

    ~MathExcOn ()
    {
	if (_changed)
	    mathExcOn (_saved);
    }

    // It is possible for functions to set the exception registers
    // yet not trigger a SIGFPE.  Specifically, the implementation
    // of pow(x, y) we're using can generates a NaN from a negative x
    // and fractional y but a SIGFPE is not generated.
    // This function examimes the exception registers and calls the
    // fpHandler if those registers modulo the exception mask are set.
    // It should be called wherever this class is commonly used where it has
    // been found that certain floating point exceptions are not being thrown.

    void handleOutstandingExceptions();

  private:

    bool                        _changed;
    int				_saved;
};


IEX_INTERNAL_NAMESPACE_HEADER_EXIT

#endif



( run in 0.420 second using v1.01-cache-2.11-cpan-f6376fbd888 )