Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!husc6!think!ames!ptsfa!ihnp4!inuxc!iuvax!pur-ee!newton.physics.purdue.edu!pur-phy!mrstve!mdbs!joe From: joe@mdbs.UUCP (Joe Greer) Newsgroups: comp.sys.ibm.pc Subject: Re: Another TURBO C Bug?? Message-ID: <365@mdbs.UUCP> Date: Tue, 7-Jul-87 08:55:03 EDT Article-I.D.: mdbs.365 Posted: Tue Jul 7 08:55:03 1987 Date-Received: Sat, 11-Jul-87 06:01:40 EDT References: <1236@ihlpm.ATT.COM> Reply-To: joe@mdbs.UUCP (Joe Greer) Organization: Micro Database Systems, Inc., Lafayette IN Lines: 33 In article <1236@ihlpm.ATT.COM> kmh@ihlpm.ATT.COM (Kirk Hoyer) writes: > >When this program is compiled and executed (I used the tcc compiler), >the values of f1 and f2 printed in the routine ffunc() are not the same >as the values printed in the main program. > >The problem seems to go away if the declaration in the main program for >ffunc() is changed as follows: > > float f1, f2, f3, ffunc( float, float ); > >Since Borland claims that both declaration styles are supported, it >seems to me that both should work. > I have run into this kind of problem with a lot of different compilers both in the MSDOS environment and in the unix environment. The problems seem to crop up when the compiler tries to support the IEEE floating point standard. By default, all floating point numbers are converted to double precision when passed through a subroutine call. The problem is that with ieee floating point, doubles and floats have very little in common and it is a non-trivial task to convert from one to the other. Now, in your example, when you passed your floats to the function, they were converted to doubles. If you look at your function, you decided to treat these doubles as floats. This results in numbers that are different (remember that unlike vaxen, ieee floats and doubles are different). This is analogous(sp?) to passing a short to a routine which expects longs. In short, *I* claim that this isn't a bug, rather it is a feature. You should use doubles if you want to let the compiler use its default type. I have yet to find a compiler that supports ieee and doesn't have this particular *feature*. Joe Greer ...ihnp4!pur-ee!mdbs!joe