hot@integow.uucp (Roland van Hout) (10/02/90)
We are using an 25 Mhz Compaq 300 Mb no FPU 8 Mb ram, and Xenix V.2.3.3. I'm expiriencing troubles with the calculation of floats: I have a float which contains :90099090001018.000000 I want add this 11.11 which is a char string, so this thru atof gives 11.110000 according to xenix this results in: 90099090001029.109000 So now we add 0.11 atoffed --> 0.110000 and we get 90099090001029.218000 then we add 1.11 atoffed --> 1.110000 according to xenix this is 90099090001030.328000, finally xenix got one right!!!!!!!! So now we add 1.11 atoffed --> 1.110000 this is 90099090001031.437000 and last but not least we add 1.10 atoffed --> 1.100000 and the result is 90099090001032.531000 I linked with -lm , so what am I doing wrong????????? -- UUCP: ..!uunet!mcsun!hp4nl!integow!hot or hot@integow.UUCP or hot@hot.mug Roland van Hout, Sr. software engineer, Integrity software consultants, Pelmolenlaan 16, 3447 GW Woerden, Netherlands, tel +31 3480-30131, fax +31 3480-30182 Sex is not the answer, sex is the question. The answer is YES!
cpcahil@virtech.uucp (Conor P. Cahill) (10/03/90)
In article <1191@integow.uucp> hot@integow.uucp (Roland van Hout) writes: >We are using an 25 Mhz Compaq 300 Mb no FPU 8 Mb ram, >and Xenix V.2.3.3. >I'm expiriencing troubles with the calculation of floats: >I have a float which contains :90099090001018.000000 The problem isn't in xenix. It isn't the compiler itself. It is that binary based hardware (like the computer you are running this stuff on) does not acurately handle floating point digits. This is a fact of life. If you need exact precision, you must use integers, find a BCD (binary coded decimal) implementation or provide your own library to act on big floating numbers (can you remember how to do long division by hand ? :-). -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc., uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170