2
Example: The division of 100 (input value) by 3 (number of plots) is equal to 33.33, where 3 * 33.33 = 99.99. Being that the right is a portion with the value 33.34.
Java code
public void parcelar() {
listaParcela = new ArrayList<>();
//if (compra.getQtdparcelas() == null) {
// if (compra.getQtdparcelas() > 1) {
Double totalP = compra.getValortotalentrada() /
compra.getQtdparcelas().doubleValue();
DateTime data = new DateTime(pagar.getVencimento());
for (int i = 1; i <= compra.getQtdparcelas(); i++) {
Cpagar par = new Cpagar();
par.setVencimento(data.toDate());
par.setValor(totalP);
par.setFormaPagamentoId(pagar.getFormaPagamentoId());
par.setObs(campoconsulta);
par.setContas(compra);
compra.getContasList().add(par);
listaParcela.add(par);
data = data.plusMonths(1);
}
}
Read more about floating point arithmetic, you can start with this question: https://answall.com/q/219211/64969
– Jefferson Quesado