I want r with only two decimal places.
double r = Math.abs ((aux5 - ((aux1*aux2)/previsoes.length))/ (Math.sqrt(Math.abs((aux3 - ((aux1 * aux1) / previsoes.length)) * (aux4 - ((aux2 * aux2) / previsoes.length))))));
I want r with only two decimal places.
double r = Math.abs ((aux5 - ((aux1*aux2)/previsoes.length))/ (Math.sqrt(Math.abs((aux3 - ((aux1 * aux1) / previsoes.length)) * (aux4 - ((aux2 * aux2) / previsoes.length))))));
You can use these two methods that leave the truncated values
If you want the results are a double:
public static double truncate(double value) {
return Math.round(value * 100) / 100d;
}
If you want a String:
public static String truncate(double value) {
DecimalFormat df = new DecimalFormat("#.00");
return df.format(value);
}
Now just call the method by passing the value of r
as an attribute, it will be transformed to a value with only two houses after the comma