diff options
author | Andrew C. Oliver <acoliver@apache.org> | 2002-07-27 01:04:58 +0000 |
---|---|---|
committer | Andrew C. Oliver <acoliver@apache.org> | 2002-07-27 01:04:58 +0000 |
commit | 3c8d54e6ffd9607b81c1f5580f00f4d69994af5a (patch) | |
tree | b016fffa2242c73fd4e95bf19700d8c105bd2cd6 /src/contrib | |
parent | 0928d1260ce898a3520faca08cd327bfb3cd2bb9 (diff) | |
download | poi-3c8d54e6ffd9607b81c1f5580f00f4d69994af5a.tar.gz poi-3c8d54e6ffd9607b81c1f5580f00f4d69994af5a.zip |
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11070
PR:
Obtained from:
Submitted by:
Reviewed by:
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352808 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/contrib')
-rw-r--r-- | src/contrib/src/org/apache/poi/hssf/contrib/view/SVFractionalFormat.java | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/contrib/src/org/apache/poi/hssf/contrib/view/SVFractionalFormat.java b/src/contrib/src/org/apache/poi/hssf/contrib/view/SVFractionalFormat.java index edf54ef2d4..36f5213892 100644 --- a/src/contrib/src/org/apache/poi/hssf/contrib/view/SVFractionalFormat.java +++ b/src/contrib/src/org/apache/poi/hssf/contrib/view/SVFractionalFormat.java @@ -133,8 +133,8 @@ public class SVFractionalFormat extends Format { if (f < 0) { sign = -1; } - double Precision = 0.0001; - double AllowedError = 0.001; + double Precision = 0.00001; + double AllowedError = Precision; double d = Math.abs(f); d -= Whole; double Frac = d; @@ -187,8 +187,7 @@ public class SVFractionalFormat extends Format { Whole++; Num = 0; Den = 0; - } else - if (Den == 0) { + } else if (Den == 0) { Num = 0; } if (sign < 0) { @@ -198,12 +197,19 @@ public class SVFractionalFormat extends Format { Whole = -Whole; } } - return new StringBuffer().append(Whole).append(" ").append(Num).append("/").append(Num).toString(); + return new StringBuffer().append(Whole).append(" ").append(Num).append("/").append(Den).toString(); } + /** This method formats the double in the units specified. + * The usints could be any number but in this current implementation it is + * halves (2), quaters (4), eigths (8) etc + */ private String formatUnit(double f, int units) { - //JMH TBD - return null; + long Whole = (long)f; + f -= Whole; + long Num = Math.round(f * units); + + return new StringBuffer().append(Whole).append(" ").append(Num).append("/").append(units).toString(); } public final String format(double val) { |