Hi all, I spent some time looking at the code in core/ and extra/ and nowhere did I spot a situation where integers and floats might be compared for equality.
Here is my rationale: - On all other types, = only returns t if the inputs have the same type. There are minor exceptions; quotations and curries are different types, and yet [ 2 + ] 2 [ + ] curry = => t, however quotations and curries are operationally equivalent. Integers and floats are not. - Considering floats and integers equal breaks transitivity of =, if you compare a bignum with a float. Eg, ( scratchpad ) 2000 2^ 1./0. = . t ( scratchpad ) 2000 2^ 1+ 1./0. = . t ( scratchpad ) 2000 2^ 2000 2^ 1+ = f - Comparing a float with an exact value is a coding mistake anyway. Code should always use order operations or ~. - The compiler will be able to perform constant propagation in some situations where it cannot do it now. - I want to change complex numbers so that a complex number with an imaginary component of floating point zero is not downgraded to a real number. This allows us to express complex numbers with an imaginary part of negative zero, and also enables further compiler optimizations. If 0 = returned f for 0.0 and -0.0, then this change would be very easy to make. - There would be a general performance improvement because equality would not need the same numeric upgrading machinery that +, < and so on use. Slava On Thu, Jul 24, 2008 at 4:00 PM, Slava Pestov <[EMAIL PROTECTED]> wrote: > Hi all, > > I plan on changing = so that a rational and a float with the same > numeric value are not considered equal. Eg, > > 10 10 = . => t > 10 10.0 = . => f > 1/2 0.5 = . => f > > You will still be able to coerce the rational to a float and then > compare, or to use a word such as ~ for approximate equality. > > Are there any objections? > > Slava > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Factor-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/factor-talk
