jpountz commented on PR #12727:
URL: https://github.com/apache/lucene/pull/12727#issuecomment-1785162374
I had a suspicion that the double promotion is not buying us anything in
that case, so I ran a quick test that seems to confirm it:
```java
long equals = 0;
long notEquals = 0;
for (float f = -100; f <= 100; f = Math.nextUp(f)) {
float a = (1f + f) / 2f;
float b = (float) ((1d + f) / 2d);
if (a == b) {
equals++;
} else {
notEquals++;
}
}
System.out.println("Equals: " + equals + ", NotEquals: " + notEquals); //
Equals: 2240806913, NotEquals: 0
```
So we don't need to promote to double and could just do `max(0, (1f + f) /
2f))`?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]