Can I trap (and recover from) floating point overflow errors?
Duncan Murdoch [dm] writes: Because the floating point processor operates in parallel to the integer processor, this is generally quite tricky. The best approach is not to trap the errors, but just to mask them, and at the end of a calculation check whether they have occurred by examining the coprocessor status word. Be aware that Borland’s string-conversion routines (used in Str, Write and Writeln) clear the FPU’s status word. If you do any I/O of floating point values in between status checks, you may miss seeing signs of errors. I would add that it’s probably best to leave the floating point overflow exception on (unmasked) in the vast majority of your code, and that you should only mask it off around the few calculations where you expect and can handle a possible overflow. That is, a runtime error is probably better than allowing the program to continue with unnoticed math errors!