IsNaN throwing exception

IsNaN throwing exception

Post by Sm9uYXRoYW » Sat, 01 May 2004 06:56:04


Hi all

An ArithmeticException is being thrown when I call Double.IsNaN() on a double whose value is NaN. The text of the exception is:

"A first chance exception of type 'System.ArithmeticException' occurred in mscorlib.dl
Additional information: Overflow or underflow in the arithmetic operation.

This bug is hard to reproduce, but once and a while I get an unhandled exception, and Double.IsNaN() is the culprit. And when it does happen, even if I handle that exception in that location, it seems like every other call to Double.IsNaN() now throws the exception when the parameter value is NaN. Also, all of the projects in my solution have the "Check for Arithmetic Overflow/Underflow" option set to false

Does anyone know what conditions cause Double.IsNaN() to throw this exception

Thanks in advance for any help on this matter

Sincerely
Jonathan DeCarlo
 
 
 

1. throw new Exception() vs. throw Exception()

2. clean-up code before throwing an exception may also throw

Hello, in my program I have a function (pseudo code):

void start_mysql_service()
{
obtain handle

start mysql service using handle

if start fails close handle and throw an exception containing error
description

else just close handle and return
}

So no matter if the service is successfully started or not, the handle needs
to be closed to prevent leakage. But the function that closes the handle may
also throw. How should I handle that? catch the close-handle-exception in
start_mysql_service()? Right now I don't catch anything in the
start_mysql_service() function so if it fails to start the service it
prepares to throw an exception, that exception never gets thrown if it the
close handle functions throws. I don't want one error hiding another one.
The real code looks like this and it's ugly (and contains some platform
specific material, sorry about that):
void
start_mysql_service()
{
/* May throw an exception. */
SC_HANDLE mysql_service = get_mysql_service_handle();

if(!StartService(mysql_service, 0, NULL))
{
/* May throw an exception and if it does I never get to throw */
/* the exception indicating that StartService() failed. */
close_service_handle(mysql_service);

/* TODO: Obtain more precise cause of error if possible using
GetLastError() and FormatMessage(). */
throw runtime_error("StartService() failed.");
}

/* May throw an exception. */
close_service_handle(mysql_service);
}


Any ideas how to restructure this into nicer-looking code and solving the
problem of one error hiding another one?

/ E

3. Assembly.CreateInstance throws "Exception has been thrown by the target of an invocation."

4. JNI's throw new does not throw an exception

5. An exception that throws while it is being thrown, no terminate?

6. MCMS 2002 SP2 Import SDO throws Exception of type 'System.OutOfMemoryException' was thrown

7. Inner exception is thrown from Control.Invoke instead of "outer" Exception, framework bug?

8. Unexpected exception is thrown while deleting an exception

9. Exception throwing that is not specified in the exception-specification.

10. Exception Exception is not compatible with throws clause in Runnable.run()

11. Unhandled exception crash when throwing std c++ exception in CE6.0

12. Is an exception specification needed if the method throws and catches its own exception?

13. Word Automation in C# app exception "The server threw an exception

14. Is an exception specification needed if the method throws and catches its own exception?

15. What the program would behave if an exception is thrown in an environment with exception disabled