[Solved] How to limit decimals digits?

[ad_1]

Just use String.format:

System.out.println(String.format("%.2f",ans));

Note that this converts your value into a String, for calculations you should keep using its numeric representation.

[ad_2]

solved How to limit decimals digits?