java convert float to 2 decimal places code example Example: java 2 decimals double res = Math.round(a * 100) / 100;