java limit outputs to 2 code example Example: java 2 decimals double res = Math.round(a * 100) / 100;