acoliver    2002/07/26 18:04:58

  Modified:    src/contrib/src/org/apache/poi/hssf/contrib/view
                        SVFractionalFormat.java
  Log:
  http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11070
  
  Revision  Changes    Path
  1.2       +13 -7     
jakarta-poi/src/contrib/src/org/apache/poi/hssf/contrib/view/SVFractionalFormat.java
  
  Index: SVFractionalFormat.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-poi/src/contrib/src/org/apache/poi/hssf/contrib/view/SVFractionalFormat.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SVFractionalFormat.java   20 Jul 2002 11:41:21 -0000      1.1
  +++ SVFractionalFormat.java   27 Jul 2002 01:04:58 -0000      1.2
  @@ -133,8 +133,8 @@
       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 @@
         Whole++;
         Num = 0;
         Den = 0;
  -    } else
  -        if (Den == 0) {
  +    } else if (Den == 0) {
         Num = 0;
       }
       if (sign < 0) {
  @@ -198,12 +197,19 @@
           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) {
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to