test_class.declarator: logger = LoggerFactory.getLogger(DecimalUtilTest.class)
test_class.modifier: private static final
test_class.original_string: private static final Logger logger = LoggerFactory.getLogger(DecimalUtilTest.class);
test_class.type: Logger
test_class.var_name: logger
test_class.file: ch-commons-util/src/test/java/com/cloudhopper/commons/util/DecimalUtilTest.java
test_class.identifier: DecimalUtilTest
test_case.body: @Test
      public void toStringWithPrecision() {
          String result = null;
          result = DecimalUtil.toString(0, 0);
          Assert.assertEquals("0", result);
  
          result = DecimalUtil.toString(1.12, 0);
          Assert.assertEquals("1", result);
  
          result = DecimalUtil.toString(1.1, 0);
          Assert.assertEquals("1", result);
  
          result = DecimalUtil.toString(1.12, 1);
          Assert.assertEquals("1.1", result);
  
          result = DecimalUtil.toString(1.12, 2);
          Assert.assertEquals("1.12", result);
  
          result = DecimalUtil.toString(1.12, 3);
          Assert.assertEquals("1.120", result);
  
          result = DecimalUtil.toString(1, 4);
          Assert.assertEquals("1.0000", result);
  
          // this causes an Exponent to be used in string representation
          double d0 = (double)1/(double)818393434343431121L;
          result = DecimalUtil.toString(d0, 2);
          Assert.assertEquals("0.00", result);
      }
test_case.class_method_signature: DecimalUtilTest.toStringWithPrecision()
test_case.full_signature: @Test public void toStringWithPrecision()
test_case.identifier: toStringWithPrecision
test_case.invocations: toString assertEquals toString assertEquals toString assertEquals toString assertEquals toString assertEquals toString assertEquals toString assertEquals toString assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void toStringWithPrecision()
focal_class.declarator: logger = LoggerFactory.getLogger(DecimalUtil.class)
focal_class.modifier: private static
focal_class.original_string: private static Logger logger = LoggerFactory.getLogger(DecimalUtil.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.file: ch-commons-util/src/main/java/com/cloudhopper/commons/util/DecimalUtil.java
focal_class.identifier: DecimalUtil
focal_class.class_method_signature: DecimalUtil.toString(double value, int precision)
focal_class.full_signature: public static String toString(double value, int precision)
focal_class.identifier: toString
focal_class.modifiers: public static
focal_class.parameters: (double value, int precision)
focal_class.return: String
focal_class.signature: String toString(double value, int precision)
focal_method.body: public static String toString(double value, int precision) {
          // create decimal format string
          StringBuilder buf = new StringBuilder("0");
          if (precision > 0) {
              buf.append(".");
          }
          for (int i = 0; i < precision; i++) {
              buf.append("0");
          }
          // create a decimal format
          DecimalFormat format = new DecimalFormat(buf.toString());
          return format.format(value);
          
          /**
          String temp = Double.toString(value);
          StringBuffer buf = new StringBuffer(temp.length()+precision);
          buf.append(temp);
          // find the '.' char
          int pos = buf.indexOf(".");
          // was the . found, if not, add it so we can use the same logic below
          if (pos < 0) {
              // if we want precision, add . and set the position correctly
              if (precision > 0) {
                  buf.append('.');
                  pos = buf.length()-1;   // set pos to last char
              } else {
                  return buf.toString();
              }
          }
          // number of digits after
          int digitsAfter = buf.length() - pos - 1;
  
          // if precision is zero, then fake getting rid of the period by incrementing this
          if (precision == 0)
              digitsAfter++;
  
          // do we need to add, delete, or keep it?
          if (digitsAfter < precision) {
              // add zeoes
              int count = precision - digitsAfter;
              for (int i = 0; i < count; i++) {
                  buf.append('0');
              }
          } else if (digitsAfter > precision) {
              // trim digits
              int count = digitsAfter - precision;
              buf.delete(buf.length()-count, buf.length());
          }
          return buf.toString();
           */
      }
focal_method.class_method_signature: DecimalUtil.toString(double value, int precision)
focal_method.full_signature: public static String toString(double value, int precision)
focal_method.identifier: toString
focal_method.invocations: append append toString format
focal_method.modifiers: public static
focal_method.parameters: (double value, int precision)
focal_method.return: String
focal_method.signature: String toString(double value, int precision)