This preview shows page 1. Sign up to view the full content.
Unformatted text preview: represented exactly in either format, the outcome of the test is false. Before calling function do_nothing, r2 is converted and stored as a double-precision number. In computing t2, two double-precision numbers are compared, yielding true. This example demonstrates a deﬁciency of GCC on IA32 machines (the same result occurs for both Linux and Microsoft Windows). The value associated with a variable changes due to operations that are not visible to the programmer, such as the saving and restoring of ﬂoating-point registers. Our experiments with the Microsoft Visual C++ compiler indicate that it does not have this problem. There are several ways to overcome this problem, although none are ideal. One is to invoke GCC with the command line ﬂag ‘-mno-fp-ret-in-387’ indicating that ﬂoating-point values should be returned on the main program stack rather than in a ﬂoating-point register. Function test1 will then show that both comparisons are true. This does not solve the problem—it just moves it to a different source of inconsistency. For example, consider the following...
View Full Document
This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.
- Spring '10
- The American