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


Semantics of Arithmetic Evaluation

When you translate programs from one language to another, be aware of the hidden pitfalls in translation. For example, an operation in one language might have similar syntax to an operation in another language without being similar semantically. Here's an example of similar functions with different syntaxes:

Languages can also differ in how they treat mixed integers and reals. For example, Fortran truncates integer quotients to integers, so 3/7 = 0 (you have to write 3.0/7.0 to obtain a fraction). The programmer translating must be aware that the results of such expressions depend on the language used.

Languages also differ in how they convert from a real number to an integer. For example, in Fortran, assigning a floating-point value to an integer rounds toward zero.

Here are the operations used to truncate a real number to an integer in three languages:


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996