Notes 

(0004595)

nicolas cellier

032806 23:53


First patch attempt.
I used a new method adaptToFloat:andCompare:
because testing against all comparison selector would otherwise speed down usual arithmetic (* +  /).
Comparison to NaN is broken, because it won't always answer false, but i think this behavior was already there before me.
2 >= NaN is true for example.
(my opinion anyway is that an exception should be raised NaN cannot be compared). 


(0004599)

nicolas cellier

032906 01:09


Second version includes new Float>>hash coming with new comparison.
TODO: rehash all the Set/Dictionary/anything else ?
(should be included in the cs)
TODO: speed up horrible Float>>hash slow down.
TODO: merge with ComplexEqualPatch
from http://bugs.impara.de/view.php?id=2688 [^]



(0011126)

nicolas cellier

091307 23:48


Some additionnal wisdom from outside:
http://www.lispworks.com/documentation/lcl50/aug/aug170.html [^]
In general, when an operation involves both a rational and a floatingpoint argument, the rational number is first converted to floatingpoint format, and then the operation is performed. This conversion process is called floatingpoint contagion. However, for numerical equality comparisons, the arguments are compared using rational arithmetic to ensure transitivity of the equality (or inequality) relation. 


(0012225)

nicolas cellier

052908 23:24


I did not test comparison with Float infinity... and a message was sent to self rather than rcvr in adaptToFloat:andCompare:
So i upload an updated test and patch
The rule i have chosen for comparison to infinity is:
every integer is less than Float infinity (and greater than negative infinity), even if it would coerce to Float infinity (resp. negative infinity).
A nasty side effect is that (13 raisedTo: 400) < (11 raisedTo: 400) asFloat.
Since asFloat inexactly coerce a finite number to infinity, such nasty effects cannot be avoided.
Another possible rule would have been to raise an Exception.



(0012226)

nicolas cellier

052908 23:29


"fix begin"
Installer mantis bug: 3374 fix:'FloatComparePatch.3.cs'.
"fix test"
Installer mantis bug: 3374 fix:'FloatCompareTest.2.cs'.
"fix end" 


(0012892)

nicolas cellier

010409 22:20


With M3374NumberHashPatchnice.1.cs , I attempt a new patch for hash based on 0006601 and with prerequisite 0006983 for #isFinite selector.
 (Float hash) is coerced to (Integer hash) when fractionPart = 0.0
else, the hash code is modified to use 56 out of 64 bits (instead of 32 out of 64)
 Integer hash is unchanged
 (Fraction hash) is coerced to (Float hash) when denominator is a power of two
otherwise, it cannot be exactly equal to a Float. I assume the Fraction is reduced
Small Float hash speed is a little downgraded, but not that much.
Big Float hash speed is degraded by a factor up to 10, but I claim these Float are rare ( see argument at 0006601 ).
Of course, one can always exhibit an unlucky example, but I prefer a slow down to a false result.
Make it right > make it fast.
I would have liked to use other Float hash algorithms like:
[ f 
f := 1.7014118346046921e38.
ByteArray hashBytes: f startingWith: Float hash] bench.
but it does not work...
And this one is slow:
[ f 
f := 1.7014118346046921e38.
((ByteArray new: 8) doubleAt: 1 put: f bigEndian: true) hash] bench.
This one is a little slower than adopted:
[ f 
f := 1.7014118346046921e38.
((f basicAt: 1) bitShift: 4) + ((f basicAt: 2) bitAnd: 16r0FFFFFFF)] bench.
I would prefer this one if hashMultiply was a fast primitive:
[ f 
f := 1.7014118346046921e38.
(((f basicAt: 1) bitShift: 4) + (f basicAt: 2) hashMultiply) hashMultiply] bench



(0012893)

nicolas cellier

010409 22:33


"fix begin"
Installer mantis ensureFix: 6983.
Installer mantis bug: 3374 fix:'M3374FloatComparePatchnice.1.cs'.
Installer mantis bug: 3374 fix:'M3374NumberHashPatchnice.1.cs'.
"fix test"
Installer mantis bug: 3374 fix:'M3374FloatCompareTestnice.1.cs'.
"fix end" 


(0013170)

nicolas cellier

071009 20:32


The new version I just uploaded is required to fix 0007361 


(0013171)

nicolas cellier

071009 20:47


"fix begin"
Installer mantis ensureFix: 6983.
Installer mantis bug: 3374 fix:'M3374FloatComparePatchnice.2.cs'.
Installer mantis bug: 3374 fix:'M3374NumberHashPatchnice.1.cs'.
"fix test"
Installer mantis bug: 3374 fix:'M3374FloatCompareTestnice.2.cs'.
"fix end" 


(0013172)

nicolas cellier

071009 21:22




(0013510)

nicolas cellier

021310 04:21


