Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: PowerPC Numerics / Part 3 - Appendixes
Appendix B - Porting Programs to PowerPC Numerics


The Invalid Exception

Many computers used to stop on an invalid operation, such as 0/0. Programmers have made the best of this and not bothered to test in advance for values that could cause an invalid operation. It is better to stop than to give a plausible but incorrect answer.

When a program written that way runs on PowerPC Numerics, it produces a NaN where it formerly would have stopped. The NaN might cause the program to take an unplanned branch and thus produce an erroneous answer. Because the program does not test for invalid operations, the user will not know whether the answers the program finally delivers have been influenced by exceptional events that formerly would have stopped the computer.

Programs sometimes contain code that depends on an ill-documented effect or on one that varies from machine to machine. If you have inherited such a program and you do not know what it does about exceptional conditions, here are some possible strategies:

If you have a program with code you can't change and you distrust the results it gives when invalid operations occur, you should set up tests that halt programming on those invalid operations and set the environment to simulate the environment in which the program was designed to run.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996