On 08/11/2017 11:38, Semyon Sadetsky wrote:
Yes "(int)+1" is also can be used for positive values, but the
"ceil()" is better since this purpose of this method, and in general
it works for negative values as well.
There may not be negative values here, so Math.ceil() is redundant.
I do not see a reason why standard function can be redundant, and why
manual implementation is better. Since even in the first version of the
fix there is an issues in manual implementation.
--Semyon
On 11/08/2017 10:24 AM, Sergey Bylokhov wrote:
Hi, Prasanta.
Is it possible that dropping the float part of "tabSize" and "x"
will cause Off-by-one error? For example:
float tabSize=3.99f;
float x=21.9f;
int tabBase=0;
649 int ntabs = ((int) x - tabBase) / (int)tabSize;
650 return tabBase + ((ntabs + 1) * tabSize);
The result is: ntabs=7 -> 31.92 which is not correct.
I guess you will need something like this:
int ntabs = (int) Math.ceil((x - tabBase) / tabSize);
return tabBase + ntabs * tabSize;
The result is: ntabs=6 -> 23.94
On 08/11/2017 03:25, Prasanta Sadhukhan wrote:
Hi All,
Bug: https://bugs.openjdk.java.net/browse/JDK-8187957
webrev: http://cr.openjdk.java.net/~psadhukhan/8187957/webrev.00/
Please review a fix for an issue where it is seen string with "tab"
in them are not aligned properly.
This is because while calculating tab stop postion, it is
calculating number of tabs in float value (an aftereffect of
JDK-8156217 <https://bugs.openjdk.java.net/browse/JDK-8156217>)
so next tab stop location is coming out wrong.
Fix is to use "number of tabs" as an integer value in order to
calculate the tab position correctly.
Regards
Prasanta
--
Best regards, Sergey.