Is there a guideline somewhere on how to deal with these issues?įrom what I hear early video game consoles were way weirder in terms of hardware constraints and available tools. Is there a C++ library that handles/detects these cases and possible errors introduced by compiler optimization? I've skimmed through the Joint Strike Fighter C++ Coding Standard but I did not find that much detail or guidelines on working with floating point arithmetic and numeric calculations. Compilers usually have some flags for FPU control words to detect such cases, but is it enough? Does it really work in practice? Maybe the majority of these cases is expected to be revealed during tests but there is no guarantee. I think it is hard to enforce it and much harder to detect if there is a case that doesn't check for validity of division/square root (Just assume adding an if condition before every single division, it's very ugly). One way to not get nan from square roots is to add an if before every single square root operation and check if the number is positive, for division check if denominator is not zero. In the comments of the same post /u/ryani has provided a very simple but interesting example where the result is off for certain range of numbers because of the way binary floating point numbers are expressed.Īnother simple example is square root or division by zero. Like space programs or software running on commercial aircraft. The comments are also very interesting and insightful.īut I cannot stop thinking about applications where accuracy and standard compliance is important. I was reading this interesting post yesterday where Torvalds is arguing that most applications do not really care about the IEEE standard and in most applications the speed is more important.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |