title: How to round long number and show it as string in android?
body: <p>Hi I have a list of files. I want to show file length of each file. I create own method for getting file length and right unit(base value). </p>
  
  <p><strong>Source</strong></p>
  
  <pre><code>public String getFileLength(long lengthBytes){
      Log.i("", 1 + " -- FILE INFO -- " + lengthBytes);
      String lengthString;
      if(lengthBytes&lt;1024){
          Log.i("", 21 + " -- FILE INFO B -- " + lengthBytes);
          lengthString = lengthBytes + " B";
          Log.i("", 22 + " -- FILE INFO B -- " + lengthString);
      } else if (lengthBytes&lt;(1024^2)){
          Log.i("", 31 + " -- FILE INFO KB -- " + lengthBytes);
          //length = String.valueOf(Math.round(i/1024)) + " KB";
          lengthString = lengthBytes/1024 + " KB";
          Log.i("", 32 + " -- FILE INFO KB -- " + lengthString);
      } else if (lengthBytes&lt;(1024^3)){
          Log.i("", 41 + " -- FILE INFO MB -- " + lengthBytes);
          lengthString = lengthBytes/(1024^2) + " MB";
          Log.i("", 42 + " -- FILE INFO MB -- " + lengthBytes);
      } else if (lengthBytes&lt;(1024^4)){
          Log.i("", 51 + " -- FILE INFO GB -- " + lengthBytes);
          lengthString = lengthBytes / (1024 ^ 3) + " GB";
          Log.i("", 52 + " -- FILE INFO GB -- " + lengthBytes);
      } else lengthString = "ERR";
  
      return lengthString;
  }
  </code></pre>
  
  <p>It shows me in application ERR. I want to debug it so I added a lot of Log.i. What logcat shows me you can see under this sentence.</p>
  
  <p><strong>Logcat shows me this:</strong></p>
  
  <pre><code>06-30 11:50:23.523    1590-1590/info.myapplication15.app I/﹕ 1 -- FILE INFO -- 292303
  06-30 11:50:24.253    1590-1590/info.myapplication15.app D/dalvikvm﹕ GC_FOR_ALLOC freed 99K, 5% free 3268K/3436K, paused 58ms, total 65ms
  06-30 11:50:24.263    1590-1590/info.myapplication15.app I/dalvikvm-heap﹕ Grow heap (frag case) to 4.330MB for 1127536-byte allocation
  06-30 11:50:24.443    1590-1599/info.myapplication15.app D/dalvikvm﹕ GC_FOR_ALLOC freed 6K, 4% free 4362K/4540K, paused 95ms, total 95ms
  06-30 11:50:25.503    1590-1590/info.myapplication15.app W/Resources﹕ Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f070040}
  06-30 11:50:25.563    1590-1590/info.myapplication15.app W/Resources﹕ Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f070041}
  06-30 11:50:25.683    1590-1590/info.myapplication15.app W/Resources﹕ Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f070042}
  06-30 11:50:26.103    1590-1590/info.myapplication15.app W/Resources﹕ Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f070040}
  06-30 11:50:26.143    1590-1590/info.myapplication15.app W/Resources﹕ Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f070041}
  06-30 11:50:26.223    1590-1590/info.myapplication15.app W/Resources﹕ Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f070042}
  06-30 11:50:26.753    1590-1590/info.myapplication15.app I/Choreographer﹕ Skipped 180 frames!  The application may be doing too much work on its main thread.
  </code></pre>
  
  <p>And I want to show string with round number and unit.
  I read that I should use <code>Math.round(i/1024)</code></p>
  
  <p>I want (File length is 292303) to show: <code>285.45 KB</code></p>