In a routine in talend open studio I wrote the following simple function which divides 2 BigDecimals and prints both the remainder of the division and the answer:
public static void returnAnswer() {
BigDecimal bd0 = new BigDecimal("3445");
BigDecimal bd1 = new BigDecimal("9");
BigDecimal[] bd2 = bd0.divideAndRemainder(bd1);
System.out.println(bd2[1].toString());
StringBuilder sb = new StringBuilder();
sb.append(bd2[0].toString()).append(".").append(Integer.toString(bd2[1].intValueExact()));
System.out.println("sb string --> " + sb.toString());
}
However the result was:
7
382.7
Instead of:
77777778
382.77777778
This happens to all the answers however I want the full answer not only 1 decimal digit, any help please would be appreciated, thanks,