Made calculations more precise
This commit is contained in:
@ -2,7 +2,7 @@ package de.vorsorge.theo.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.math.MathContext;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
@ -162,14 +162,13 @@ public class FabianUtil {
|
||||
@Override
|
||||
public void log() {
|
||||
BigDecimal counter = getCounter();
|
||||
BigDecimal percentage = BigDecimal.valueOf(100).divide(total, 15, RoundingMode.HALF_UP).multiply(counter);
|
||||
|
||||
BigDecimal percentage = BigDecimal.valueOf(100).divide(total, MathContext.DECIMAL64).multiply(counter);
|
||||
Duration timePassed = getTimePassed();
|
||||
|
||||
String remainingTimePart = "";
|
||||
if (counter.signum() != 0) {
|
||||
BigDecimal secondsPassed = BigDecimal.valueOf(timePassed.getSeconds());
|
||||
BigDecimal totalSeconds = secondsPassed.divide(counter, 15, RoundingMode.HALF_UP).multiply(total);
|
||||
BigDecimal totalSeconds = secondsPassed.divide(counter, MathContext.DECIMAL64).multiply(total);
|
||||
BigDecimal secondsToGo = totalSeconds.subtract(secondsPassed);
|
||||
Duration timeToGo = Duration.of(secondsToGo.longValue(), ChronoUnit.SECONDS);
|
||||
remainingTimePart = ", " + formatDuration(timeToGo) + " verbleibend";
|
||||
|
Reference in New Issue
Block a user