Re: CDC Floating point = tests?



stocksami@xxxxxxxxxxxxx wrote:

On the old CDC machines running EKS you could use a regular if test to see if two floating point values were equal, and it worked! I've ported lots of code from EKS to other platforms and I've had to change those lines of codes many many times.

Two equal normalized floating point values should compare equal
as fixed point, assuming that all bits go into both comparisons.
(Note, for example, that on the 704 only 16 bits of a 36 bit word
are used for fixed point. I don't know if all 36 are compared.)

Some machines stored floating point values unnormalized, such
that integer values stored as floating point would compare
equal to the same integer stored in fixed point.

Also, there are machines that are designed to compare fixed and
float with the same instructions. The PDP-10 stores negative
floating point by twos complementing the whole word, such that
greater than, equal to, and less than can all be done with fixed
point compare. (The only one that is supplied.)

> I'm currently doing another
upgrade to one of those programs. It would read in floating point values with formatted read statements and compare to other floating point values. They weren't integer values either. The code relied heavily on this and it worked fine. How did this work? How did the CDC compiler handle this?

In general, it is recommended not to do equality tests on floating point. Among others, the compiler and run time library don't always
use the same conversion routines. Also, constant expressions evaluated
at compile time may be different than expressions evaluated at run time.
(Even without the problems of excess precision.)

-- glen

.



Relevant Pages

  • Re: Comparing floating point values in Java
    ... when comparing floating point values in computers. ... In Java, will unchanged values compare strictly true if equal? ... In strictfp mode, the exact, bit-by-bit, result is predictable from the ...
    (comp.lang.java.programmer)
  • Re: Comparing floating point values in Java
    ... when comparing floating point values in computers. ... In Java, will unchanged values compare strictly true if equal? ... In strictfp mode, the exact, bit-by-bit, result is predictable from the ...
    (comp.lang.java.programmer)
  • Re: addition of 0.7 and 0.1 is not 0.8 CDbl / CStr vbs problem
    ... Comparing floating point values should be done using a tolerance:- ... In other cases the resulting 'near enough' value stored after a calculation ... the situation using CDbl) than to compare with "almost near ... CStr may no longer be what you want. ...
    (microsoft.public.scripting.vbscript)
  • Re: Can anyone repeat this?
    ... incrementing and decrementing by .01 (as represented by the compiler), ... Not a good idea to compare floating points like this though. ...
    (microsoft.public.vc.mfc)
  • Re: Strange basic problem with comparision of two varialbes defined as double
    ... > My application does need to compare a lot of values for accounting purposes. ... store data in floating point format to simplify the problem. ... those fractions representable by binary fractions are ... Your alternatives are to either use a representation that deals with the ...
    (microsoft.public.vstudio.development)