Bug 55419 - New fraction formatting throws SimpleFractionException due to incorrect MAX_VALUE in overflow
Summary: New fraction formatting throws SimpleFractionException due to incorrect MAX_V...
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 3.10-dev
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2013-08-14 21:01 UTC by Robert Kish
Modified: 2013-08-15 01:47 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
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.