Bug 55419

Summary: New fraction formatting throws SimpleFractionException due to incorrect MAX_VALUE in overflow
Product: POI Reporter: Robert Kish <robert_kish>
Component: POI OverallAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 3.10-dev   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

Description Robert Kish 2013-08-14 21:01:30 UTC
A SimpleFractionException is being thrown on what should be a very easy case to format: 
Format 123456.6 as a fraction with single digit numerator and denominator.
It is expected to format as 123456 3/5

Instead, I get:

org.apache.poi.ss.usermodel.FractionFormat$SimpleFractionException: Greater than overflow in loop 0.600000, 20615843021, 34359738368
	at org.apache.poi.ss.usermodel.FractionFormat.calcFractionMaxDenom(FractionFormat.java:217)
	at org.apache.poi.ss.usermodel.FractionFormat.format(FractionFormat.java:133)
	at org.apache.poi.ss.usermodel.FractionFormat.format(FractionFormat.java:172)


When looking at the code in FractionFormat, method calcFractionMaxDenom, I see that it is setting an overflow variable, of type long, to Integer.MAX_VALUE.

In my test area, when I set the value to Long.MAX_VALUE, the function correctly returns the data I expect.
Comment 1 Tim Allison 2013-08-15 00:12:05 UTC
MATH-996 hasn't made it into MATH yet or here.  Will apply that fix, and try to refactor out my previous patch...on my to do list, thanks to Nick for pointing it out earlier.  Thank you for submitting this.
Comment 2 Tim Allison 2013-08-15 01:47:49 UTC
Fixed in r1514123. Thank you, again, for submitting this.