Round number to only first decimal place

前端 未结 3 575
渐次进展
渐次进展 2021-01-21 10:17

I would like to know the available phone memory, so I wrote this code.

File path2 = Environment.getDataDirectory();
StatFs stat2 = new StatFs(path.getPath());
lo         


        
3条回答
  •  一生所求
    2021-01-21 11:09

    If I understood your question right you need NumberFormat here:

    NumberFormat nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(1);
    nf.format(5.654707363);
    

    produces 5,7

提交回复
热议问题