Package java.math

Examples of java.math.BigDecimal.toPlainString()


   */
  public void testToPlainStringPosPosExp() {
    String a = "123809648392384754573567356745735.63567890295784902768787678287E+100";
    BigDecimal aNumber = new BigDecimal(a);
    String result = "1238096483923847545735673567457356356789029578490276878767828700000000000000000000000000000000000000000000000000000000000000000000000";
    assertTrue("incorrect value", aNumber.toPlainString().equals(result));
  }

  /**
   * Convert a negative BigDecimal to a string representation.
   */
 
View Full Code Here


                    case Types.DECIMAL:
                    case Types.NUMERIC:
                       BigDecimal bigDecimal = rs.getBigDecimal(i);
                       if (bigDecimal != null)
                           returnValue = bigDecimal.toPlainString();
                       break;

                    case Types.BIT:
                    case Types.BOOLEAN:
                       if ("bool".equalsIgnoreCase((rs.getMetaData().getColumnTypeName(i))) || "boolean".equalsIgnoreCase((rs.getMetaData().getColumnTypeName(i))))
View Full Code Here

    long amount_int = 23385868;

    // FYI DO NOT divide like this
    BigDecimal testAmount = new BigDecimal((double) amount_int / BTC_VOLUME_AND_AMOUNT_INT_2_DECIMAL_FACTOR);
    assertThat(testAmount.toPlainString()).isEqualTo("0.2338586800000000132104815975253586657345294952392578125");

    // FYI DO divide like this
    BigDecimal testAmount2 = new BigDecimal(amount_int).divide(new BigDecimal(BTC_VOLUME_AND_AMOUNT_INT_2_DECIMAL_FACTOR));
    assertThat(testAmount2.toPlainString()).isEqualTo("0.23385868");
View Full Code Here

    BigDecimal testAmount = new BigDecimal((double) amount_int / BTC_VOLUME_AND_AMOUNT_INT_2_DECIMAL_FACTOR);
    assertThat(testAmount.toPlainString()).isEqualTo("0.2338586800000000132104815975253586657345294952392578125");

    // FYI DO divide like this
    BigDecimal testAmount2 = new BigDecimal(amount_int).divide(new BigDecimal(BTC_VOLUME_AND_AMOUNT_INT_2_DECIMAL_FACTOR));
    assertThat(testAmount2.toPlainString()).isEqualTo("0.23385868");

  }
}
View Full Code Here

            exchange.getIn().setHeader(GeoCoderConstants.ADDRESS, res.getResults().get(0).getFormattedAddress());
            // just grab the first element and its lat and lon
            BigDecimal resLat = res.getResults().get(0).getGeometry().getLocation().getLat();
            BigDecimal resLon = res.getResults().get(0).getGeometry().getLocation().getLng();
            exchange.getIn().setHeader(GeoCoderConstants.LAT, resLat.toPlainString());
            exchange.getIn().setHeader(GeoCoderConstants.LNG, resLon.toPlainString());
            String resLatlng = resLat.toPlainString() + "," + resLon.toPlainString();
            exchange.getIn().setHeader(GeoCoderConstants.LATLNG, resLatlng);

            GeocoderAddressComponent country = getCountry(res);
            if (country != null) {
View Full Code Here

            // just grab the first element and its lat and lon
            BigDecimal resLat = res.getResults().get(0).getGeometry().getLocation().getLat();
            BigDecimal resLon = res.getResults().get(0).getGeometry().getLocation().getLng();
            exchange.getIn().setHeader(GeoCoderConstants.LAT, resLat.toPlainString());
            exchange.getIn().setHeader(GeoCoderConstants.LNG, resLon.toPlainString());
            String resLatlng = resLat.toPlainString() + "," + resLon.toPlainString();
            exchange.getIn().setHeader(GeoCoderConstants.LATLNG, resLatlng);

            GeocoderAddressComponent country = getCountry(res);
            if (country != null) {
                exchange.getIn().setHeader(GeoCoderConstants.COUNTRY_SHORT, country.getShortName());
View Full Code Here

     */
     public void testToPlainStringNegNegExp() {
        String a = "-123809648392384754573567356745735.63567890295784902768787678287E-100";
        BigDecimal aNumber = new BigDecimal(a);
        String result = "-0.000000000000000000000000000000000000000000000000000000000000000000012380964839238475457356735674573563567890295784902768787678287";
        assertTrue("incorrect value", aNumber.toPlainString().equals(result));
    }

    /**
     * Convert a negative BigDecimal with a positive exponent
     * to a plain string representation;
View Full Code Here

     */
     public void testToPlainStringNegPosExp() {
        String a = "-123809648392384754573567356745735.63567890295784902768787678287E100";
        BigDecimal aNumber = new BigDecimal(a);
        String result = "-1238096483923847545735673567457356356789029578490276878767828700000000000000000000000000000000000000000000000000000000000000000000000";
        assertTrue("incorrect value", aNumber.toPlainString().equals(result));
    }

    /**
     * Convert a positive BigDecimal with a negative exponent
     * to a plain string representation;
View Full Code Here

     */
     public void testToPlainStringPosNegExp() {
        String a = "123809648392384754573567356745735.63567890295784902768787678287E-100";
        BigDecimal aNumber = new BigDecimal(a);
        String result = "0.000000000000000000000000000000000000000000000000000000000000000000012380964839238475457356735674573563567890295784902768787678287";
        assertTrue("incorrect value", aNumber.toPlainString().equals(result));
    }

    /**
     * Convert a negative BigDecimal with a negative exponent
     * to a plain string representation;
View Full Code Here

     */
     public void testToPlainStringPosPosExp() {
        String a = "123809648392384754573567356745735.63567890295784902768787678287E+100";
        BigDecimal aNumber = new BigDecimal(a);
        String result = "1238096483923847545735673567457356356789029578490276878767828700000000000000000000000000000000000000000000000000000000000000000000000";
        assertTrue("incorrect value", aNumber.toPlainString().equals(result));
    }

    /**
     * Convert a BigDecimal to a string representation;
     * scale == 0.
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.