Print Integer with 2 decimal places in Java

后端 未结 7 893
轻奢々
轻奢々 2020-12-16 15:10

in my code i use integers multiplied by 100 as decimals (0.1 is 10 etc). Can you help me to format output to show it as decimal?

相关标签:
7条回答
  • 2020-12-16 15:55
    int x = 100;
    DecimalFormat df = new DecimalFormat("#.00"); // Set your desired format here.
    System.out.println(df.format(x/100.0));
    
    0 讨论(0)
提交回复
热议问题