I am building a simple inventory and sales app, so i wrote a profit calculation method in android to get the profits from all products as total profit and display it in TextView on the app. The values are in double so I wrote this method below to get the total profit but the output is a bit weird, it show's something like "2.45116E7" or "1.22558E7" and so on as it changes each time I run the app but has same format as the total profit. So I added Log.d to trace the outputs inside of the method and I realized that the method does get the profit values from each product and adds them up as the total profit but as soon as the total profit reaches 10,000,000 or above it changes to that output. Please I need help to understand what is wrong and possible solutions. See the method below with the screenshot of the Log.d outputs.
private double getStoreProfits() {
for (Product product : products) {
Log.d("Profit", String.valueOf(product.getProfit()));
totalProfit += product.getProfit();
Log.d("Total Profits", String.valueOf(totalProfit));
}
return totalProfit;
}
The output: