On 09/11/2017 01:56, Prasanta Sadhukhan wrote:
So, I guess, as Semyon suggested, making the "result of the sentence should be  truncated to int, not its members" should be the way to go.

Thank you for clarification, then this solution looks fine.


Lastly, could you please suggest as to how to automate this test?

Regards
Prasanta
On 11/9/2017 8:36 AM, semyon.sadet...@oracle.com wrote:
On 11/8/17 12:24 PM, Sergey Bylokhov wrote:

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.
I don't see it standard, just redundant in the case. What did you mean under "manual implementation"?

--Semyon


--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.

Reply via email to