U++ framework
Do not panic. Ask here before giving up.

Home » Extra libraries, Code snippets, applications etc. » C++ language problems and code snippets » FP exception vs NaN
Re: Capture division by zero [message #55282 is a reply to message #55281] Tue, 27 October 2020 11:40 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
koldo wrote on Tue, 27 October 2020 11:38
mirek wrote on Tue, 27 October 2020 11:16
Yet another example, how are you going to fix this:

double SomeFunction(double x)
{
    return ln(x*x*x - 15*x*x + x + 20);
}


Now this function is used throughout your code on 50 places and you have got an exception because the argument is negative.

How are you going to fix it?

This is the main problem I have encounterd with "activate FP exception" approach and I still do not know the correct solution....

Mirek
In my code I would put an ASSERT to capture the error in DEBUG. Just like Vector checks if index is negative.


Yeah, so your program now does not work in debug for particular input data. What is the next step?

Mirek

[Updated on: Tue, 27 October 2020 11:41]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Dumb bug. Improper use of Null
Next Topic: strange MinGw return
Goto Forum:
  


Current Time: Thu Sep 03 22:45:41 GMT+2 2026

Total time taken to generate the page: 0.00957 seconds