aherbert commented on PR #142: URL: https://github.com/apache/commons-numbers/pull/142#issuecomment-2332496226
Note: In your Lucene code you are using the float method with an int ulp ([Lucene PR 13723](https://github.com/apache/lucene/pull/13723)). Given you are not tied to the legacy API that Numbers inherited from Commons Math I would recommend you change the ulp argument to a `short` and adapt the double equality method. It is much cleaner. If you consider the distance apart that 2 float values are at different ulp you will note that it is not a suitable measure of closeness when beyond the value of a `short`: ``` jshell> Float.intBitsToFloat(Float.floatToRawIntBits(1.0f) + (1 << 10)) $10 ==> 1.0001221 jshell> Float.intBitsToFloat(Float.floatToRawIntBits(1.0f) + (1 << 12)) $11 ==> 1.0004883 jshell> Float.intBitsToFloat(Float.floatToRawIntBits(1.0f) + (1 << 14)) $12 ==> 1.0019531 jshell> Float.intBitsToFloat(Float.floatToRawIntBits(1.0f) + (1 << 15)) $13 ==> 1.0039062 jshell> Float.intBitsToFloat(Float.floatToRawIntBits(1.0f) + (1 << 16)) $14 ==> 1.0078125 ``` When you have two floats at ~32000 ulp apart then you can switch to using a relative or absolute delta. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
