List of usage examples for java.math BigDecimal multiply
public BigDecimal multiply(BigDecimal multiplicand)
(this × multiplicand)
, and whose scale is (this.scale() + multiplicand.scale()) . From source file:edu.ku.brc.specify.config.LatLonConverter.java
/** * @param dm/*from ww w. ja va 2s. co m*/ * @return */ public static BigDecimal convertDirectionalDDMMMMToDDDD(final String dm) { String[] parts = StringUtils.split(dm, " d'\"" + DEGREES_SYMBOL); String dir = null; if (parts.length < 3) { parts[1] = parts[1].replaceAll("[NSEW]", ""); int beginIndex = dm.indexOf(parts[1]) + parts[1].length(); dir = dm.substring(beginIndex, beginIndex + 1); } else { dir = parts[2].substring(0, 1); } double p0 = parseDouble(parts[0]); double p1 = parseDouble(parts[1]); BigDecimal val = new BigDecimal(p0 + (p1 / 60.0)); if (isNegative(dir)) { val = val.multiply(minusOne); } return val; }
From source file:edu.ku.brc.util.LatLonConverter.java
/** * Converts Degrees decimal Minutes to BigDecimal. * @param bd the DigDecimal to be converted. * @param direction the direction//from w ww . j ava 2 s.co m * @return a BigDecimal */ public static BigDecimal convertDDMMMMStrToDDDDBD(final String str, final String direction) { BigDecimal bd = convertDDMMMMStrToDDDDBD(str); if (isNegative(direction)) { return bd.multiply(minusOne); } return bd; }
From source file:edu.ku.brc.util.LatLonConverter.java
/** * @param str/*from w w w .ja v a 2 s. com*/ * @return */ public static BigDecimal convertDirectionalDDDDToDDDD(final String str) { String[] parts = StringUtils.split(str, " d'\"" + DEGREES_SYMBOL); String dir = null; if (parts.length < 2) { parts[0] = parts[0].replaceAll("[NSEW]", ""); int beginIndex = str.indexOf(parts[0]) + parts[0].length(); dir = str.substring(beginIndex, beginIndex + 1); } else { dir = parts[1].substring(0, 1); } double p0 = UIHelper.parseDouble(parts[0]); BigDecimal val = new BigDecimal(p0); if (isNegative(dir)) { val = val.multiply(minusOne); } return val; }
From source file:edu.ku.brc.util.LatLonConverter.java
/** * Converts Degrees, Minutes and Decimal Seconds to BigDecimal. * @param bd the DigDecimal to be converted. * @param direction the direction// w ww . j a v a2 s .co m * @return a BigDecimal */ public static BigDecimal convertDDMMSSStrToDDDDBD(final String str, final String direction) { BigDecimal bd = convertDDMMSSStrToDDDDBD(str); if (isNegative(direction)) { return bd.multiply(minusOne); } return bd; }
From source file:org.csware.ee.utils.Tools.java
public static double multiply(double v1, double v2) { BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b2 = new BigDecimal(Double.toString(v2)); return b1.multiply(b2).doubleValue(); }
From source file:edu.ku.brc.specify.config.LatLonConverter.java
/** * @param str/* ww w. j a v a2 s . co m*/ * @return */ public static BigDecimal convertDirectionalDDMMSSToDDDD(final String str) { String[] parts = StringUtils.split(str, " d'\"" + DEGREES_SYMBOL); String dir = null; if (parts.length < 4) { parts[2] = parts[2].replaceAll("[NSEW]", ""); int beginIndex = str.indexOf(parts[2]) + parts[2].length(); dir = str.substring(beginIndex, beginIndex + 1); } else { dir = parts[3].substring(0, 1); } double p0 = parseDouble(parts[0]); double p1 = parseDouble(parts[1]); double p2 = parseDouble(parts[2]); BigDecimal val = new BigDecimal(p0 + ((p1 + (p2 / 60.0)) / 60.0)); if (isNegative(dir)) { val = val.multiply(minusOne); } return val; }
From source file:edu.ku.brc.util.LatLonConverter.java
/** * Converts Degrees decimal Minutes to BigDecimal. * @param bd the DigDecimal to be converted. * @return a BigDecimal//from w ww . j a va 2s. c o m */ public static BigDecimal convertDDMMMMStrToDDDDBD(final String str) { String[] parts = StringUtils.split(str, " dm'\"" + DEGREES_SYMBOL); double p0 = UIHelper.parseDouble(parts[0]); boolean neg = false; if (p0 < 0) { p0 = p0 * -1; neg = true; } Double p1 = UIHelper.parseDouble(parts[1]); if (p1 != null) { BigDecimal val = new BigDecimal(p0 + (p1 / 60.0)); if (neg) { val = val.multiply(minusOne); } return val; } return null; }
From source file:edu.ku.brc.util.LatLonConverter.java
/** * Converts Decimal Degrees to BigDecimal. * @param bd the DigDecimal to be converted. * @param direction the direction/* ww w.j av a2s . com*/ * @return a BigDecimal */ public static BigDecimal convertDDDDStrToDDDDBD(final String str, final String direction) { String val = StringUtils.replace(StringUtils.replace(str, decimalSep, ""), "-", ""); if (!StringUtils.isNumeric(val)) { return null; } BigDecimal bd = UIHelper.parseDoubleToBigDecimal(str); if (isNegative(direction)) { return bd.multiply(minusOne); } return bd; }
From source file:edu.ku.brc.util.LatLonConverter.java
/** * Converts Degrees, Minutes and Decimal Seconds to BigDecimal. * @param bd the DigDecimal to be converted. * @return a BigDecimal/* w w w. j a v a 2 s . c o m*/ */ public static BigDecimal convertDDMMSSStrToDDDDBD(final String str) { String[] parts = StringUtils.split(str, " d'\"" + DEGREES_SYMBOL); if (parts.length != 3) { return null; } double p0 = UIHelper.parseDouble(parts[0]); boolean neg = false; if (p0 < 0) { p0 = p0 * -1; neg = true; } double p1 = UIHelper.parseDouble(parts[1]); double p2 = UIHelper.parseDouble(parts[2]); BigDecimal val = new BigDecimal(p0 + ((p1 + (p2 / 60.0)) / 60.0)); if (neg) { val = val.multiply(minusOne); } return val; }
From source file:edu.ku.brc.util.LatLonConverter.java
/** * @param dm//from w ww . j av a 2 s . co m * @return */ public static BigDecimal convertDirectionalDDMMMMToDDDD(final String dm) { String[] parts = StringUtils.split(dm, " d'\"" + DEGREES_SYMBOL); String dir = null; if (parts.length < 3) { parts[1] = parts[1].replaceAll("[NSEW]", ""); int beginIndex = dm.indexOf(parts[1]) + parts[1].length(); dir = dm.substring(beginIndex, beginIndex + 1); } else { dir = parts[2].substring(0, 1); } double p0 = UIHelper.parseDouble(parts[0]); double p1 = UIHelper.parseDouble(parts[1]); BigDecimal val = new BigDecimal(p0 + (p1 / 60.0)); if (isNegative(dir)) { val = val.multiply(minusOne); } return val; }