Fix issues handling floating point numbers #356
There are two issues at play here, discovered while implementing
The test suite is extended with tests for both zero and NaN.
There are two issues at play here, discovered while implementing ArrayList#contains: - Boxing elimination replaces +0.0 values with -0.0 values that were defined ealier in the code (or the other way around). This happens because the the F32/F64 case classes synthesize the standard equals implementation which uses == and considers +0.0/-0.0 equal (and identical NaNs values never equal). This is fixed by providing an equals method that compares the raw bits instead, making sure that we only deduplicate values that have the same bits. - The ArrayList#contains method was still failing as Float#equals and Double#equals were using ==. This was fixed by comparing the processed bits (all NaN bit patterns are collapsed into one). The test suite is extended with tests for both zero and NaN.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments.