On Fri, 26 Jul 2024 17:00:28 GMT, Alisen Chung <[email protected]> wrote:

>> Math.ceil call with integer argument is redundant as it returns the same 
>> value without Math.ceil, so it is removed..
>> CI testing is green and JDK-8202013 regression testcase for which the code 
>> was added, is not affected..
>
> src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java line 
> 2394:
> 
>> 2392:             int gap = isLeftToRight ? - (bulletgap + size/3) : (aw + 
>> bulletgap);
>> 2393:             int x = ax + gap;
>> 2394:             int y = Math.max(ay, ay + ah/2);
> 
> Rather than redundant, wasn't this code just incorrect? For example int 3/2 
> is 1 and ceiling that after is still 1, but I assume that the original 
> purpose of the code was to make ceil(3/2)=2? Should this be fixed to divide 
> as a float then ceil it afterwards?

I was thinking exactly the same when I saw this.
Perhaps the coder meant "ah/2.0" which would promote the result to a double on 
which Math.ceil WOULD do something useful.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20358#discussion_r1694350095

Reply via email to