0

I more or less understand / imagine the typical user-defined logic which is executed:

  • after FE_OVERFLOW or FE_UNDERFLOW is raised: not critical case: try to recover by, for example, adjusting some values / coefficients and redo the computations;
  • after FE_INVALID or FE_DIVBYZERO is raised: critical case: stop the machine OR reboot the machine.

However, what is the typical user-defined logic which is executed after FE_INEXACT is raised? Any examples, experiences, best practices?

Extra: In presentation «Beyond Floating Point: Next-Generation Computer Arithmetic» John L. Gustafson provides the following opinion (page 5):

the “inexact” flag is useless

Any comments / views on this opinion?

pmor
  • 5,392
  • 4
  • 17
  • 36
  • If inexact, you can run it with a higher precision. (i.e., if you were using single-precision, use double; if using double, use quad, etc.) It's just as useful as overflow/underflow in that sense. Perhaps what's not helpful is that you get no indication as to what you should do to recover, aside from "try with higher precision," which may or may not handle the problem. – alias May 02 '21 at 19:22
  • If you have a data batch on which yu are computing statistics, this may be a sample that you drop from the batch. – stark May 02 '21 at 20:23
  • Users alias and stark: thanks for your comments! Useful ideas! Will take into account. – pmor May 04 '21 at 13:36
  • Because there are default results provided when default exception handling is enabled (traps are disabled), what a program does when it enables traps is by definition atypical. It is not completely illogical to ask for the typical atypical use—it may be like asking for the second-most favored behavior—but the lack of answers suggests there is not much to say. IEEE 754 provides a set of tools people can use any way they want. – Eric Postpischil May 13 '21 at 10:41
  • Speculating somewhat, trapping inexact could be used to detect errors in software intended to perform exact computations. The 53-bit significand of the double format is at times useful on processors that provide only 32-bit integer arithmetic, so some software uses floating-point to perform integer arithmetic. Trapping inexact would be useful error detection. Beyond that, I could imagine uses in which inexact triggers use of more precision, but I cannot say I recall anybody doing that. – Eric Postpischil May 13 '21 at 10:46

0 Answers0