The following Code
private double roundTheReading(double toRoundValue) { double roundetValue = 0; if (formatter == null){ DecimalFormatSymbols dfs = new DecimalFormatSymbols(); dfs.setDecimalSeparator('.'); formatter = new DecimalFormat(("#0." + zerosAfterDot),dfs); } roundetValue = Double.parseDouble(formatter.format(toRoundValue)); return roundetValue; } makes a shorting of the double "toRoundValue" because it haves 9 after dot characters and i need only 0, 1 or 2 of them (is set by zerosAfterDot by an Input Method).
Problem is: if zerosAfterDot is "0" the answer should be 5 or 3421. I get the . and 1 Zero everytime (5.0 3421.0).
Dose this have something to do with the Line:
formatter = new DecimalFormat(("#0." + zerosAfterDot),dfs); Is the dot in this line the dot i get in my output? If so i could make an If() what checks if the value fter the dot is zero. But i would rather not do that because it would also kill the Dot if the zerosAfterDot > 0. And i want to get around to many if statements.
TL,DR How do i get rid of the "." when i dont have numbers following it that are significant?