List of utility methods to do BigDecimal
BigDecimal | getFloatingPoint(Console console, Function get Floating Point if (validator == null) validator = value -> true; String answer; BigDecimal value; do { answer = readLine(console); try { value = stripAndOrRescale(new BigDecimal(answer)); ... |
String | getFormattedBigDecimal(BigDecimal value) get Formatted Big Decimal if (value.compareTo(DISPLAY_MAX) > 0) { return "very high"; int unitIndex = 0; for (; unitIndex < UNIT.length && value.compareTo(THOUSAND) > 0; unitIndex++) { value = value.divide(THOUSAND); if (unitIndex == 0) { ... |
BigDecimal | getFraction(BigDecimal b) get Fraction return b.abs().subtract(b.abs().setScale(0, BigDecimal.ROUND_FLOOR).abs()).abs();
|
BigDecimal | getFractionalPart(BigDecimal value) get Fractional Part if (value == null) { return value; BigDecimal fractionalPart = value.subtract(value.setScale(0, RoundingMode.FLOOR)); return (fractionalPart.compareTo(BigDecimal.ZERO) != 0) ? fractionalPart : null; |
BigDecimal | getId(BigDecimal total, BigDecimal step) get Id return step.multiply(new BigDecimal(RANDOM.nextInt(total.intValue()))); |
int | getIntLength(BigDecimal val) The digit number of an integer part is acquired. BigInteger intVal = val.unscaledValue(); intVal = intVal.abs(); String bak = intVal.toString(); return bak.length(); |
int | getIntValue(BigDecimal b) get Int Value if (b == null) { return 0; return b.intValue(); |
int | getLength(BigDecimal v) get Length int signum = v.signum(); if (signum == 0) { return 1; return (signum < 0 ? 2 : 1) + (v.precision() + 1 + (v.scale() % 2 == 0 ? 0 : 1)) / 2; |
BigDecimal | getLet(BigDecimal nl, BigDecimal el) get Let BigDecimal lat_jp = getLetJp(nl); BigDecimal lon_jp = getLonJp(el); return lat_jp.subtract(lat_jp.multiply(new BigDecimal(0.00010695))) .add(lon_jp.multiply(new BigDecimal(0.000017464))).add(new BigDecimal(0.0046017)) .setScale(7, BigDecimal.ROUND_HALF_UP); |
BigDecimal | getLetJp(BigDecimal nl) get Let Jp return nl.divide(new BigDecimal(3600000), 7, BigDecimal.ROUND_HALF_UP); |