Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Extra libraries, Code snippets, applications etc. » C++ language problems and code snippets » FP exception vs NaN
Re: Capture division by zero [message #55278 is a reply to message #55273] Tue, 27 October 2020 11:09 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Tue, 27 October 2020 10:58
CrashHandler works only in DEBUG and is connected to TheIDE so when debugging you can capture floating point (FP) and other problems. Production code could not use CrashHandler.


Which is another stupid mistake. You expect to catch all those FP bugs during debugging? I can tell with 100% probability that you are going to miss something, because it all depends on input data. So the end result of your effort will be that in release you will be getting unexpected NaNs and the whole thing will collapse.

Quote:

Division by zero and other FP errors, are errors and have to be debugged. Just imagine two situations:
- The calculation of your bank account balance is infinite Smile


No. If the end result of complex operation is infinite, the whole operation has to be rejected. In your application, it will be infinite, because you thought that you have fixed all FP bugs and you do not have any safeguards for unexpected inputs

Quote:

- The controller that determines the direction of your car with automatic driving sets an infinite angle Sad


Which is exactly what can happen with your approach. Correctly written code will reject invalid angle.

Quote:
I do not want my code to fall in these situations.


But you are going exactly into that trap. As I said, been there....

Mirek


 
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: Tue May 07 18:33:27 CEST 2024

Total time taken to generate the page: 0.01391 seconds