[ 
https://issues.apache.org/jira/browse/PDFBOX-1079?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13073336#comment-13073336
 ] 

Guillaume Bailleul commented on PDFBOX-1079:
--------------------------------------------

No that's not your machine.

I encountered that problem, but it was disappearing when I was looking at it. 
With Aaron's description, it was easier to understand why it was not so 
frequent.

But the value of 0.02 is not enough, this code is an example where 2 
consecutively coded float are distant of more than 0.2 :

int si = 1216919551;
float sf = Float.intBitsToFloat(si);
int ei = si+1;
float ef1 = Float.intBitsToFloat(ei);
float ef2 = sf+ 0.01f;
System.out.println(sf);
System.out.println(ef1);
System.out.println(ef2);

I propose a patch that use Float method to create 2 consecutive float (if I 
understood enough float coding). This patch target the same line.

> TestCOSFloat occasionally fails: Is something wrong with my machine?
> --------------------------------------------------------------------
>
>                 Key: PDFBOX-1079
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1079
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 1.7.0
>         Environment: Windows Vista, HP Pavilion, NetBeans, Java is probably 
> version 1.6.0_25
>            Reporter: Aaron Stewart
>            Priority: Minor
>         Attachments: testfloat.patch
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> In org.apache.pdfbox.cos.TestCOSFloat, testEquals() fails when num is close 
> to 1.0f.  
> I originally encountered the problem as an occasional failure while building 
> the unmodified source code.
> I can get the failure consistently by setting num to 1.0f explicitly in the 
> code and running the test.  
> The problem occurs on this line, on the last iteration of the loop, when i is 
> 280000f and num is close to 280000f.
> COSFloat test4 = new COSFloat(num + 0.01f);
> It passes consistently on my machine if I change this value to 0.02f.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to