Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>That is Scientific Notation.</p> <p>AND you are getting 388 instead of 311 because you are dividing by 1000000 instead of 1048576 (1024 * 1024)</p> <p>EDIT: 311 is not achieved even with 1048576, that way you get 370... so the error is probably in your calc ;)</p> <p>As <a href="https://stackoverflow.com/questions/6878623/scientific-notation-to-decimal">described here</a> , you just have to convert your Scientific Notation to a Decimal Notation through a Formatter.</p> <pre><code>DecimalFormat df = new DecimalFormat("#.########"); return df.format(fileLengthMegabytes); </code></pre> <p><strong>Running Example</strong>: <a href="http://ideone.com/2lkKv7" rel="noreferrer">http://ideone.com/2lkKv7</a></p> <pre><code>import java.util.*; import java.lang.*; import java.text.*; class Main { public static void main (String[] args) throws java.lang.Exception { DecimalFormat df = new DecimalFormat("#.##########"); float fileLengthMegabytes1 = (float) 388 / 1000000; float fileLengthMegabytes2 = (float) 388 / 1048576; System.out.println("MB1 in Scientific Notation: " + fileLengthMegabytes1); System.out.println("MB1 in Decimal Notation: " + df.format(fileLengthMegabytes1)); System.out.println("MB2 in Scientific Notation: " + fileLengthMegabytes2); System.out.println("MB2 in Decimal Notation: " + df.format(fileLengthMegabytes2)); } } </code></pre> <p>Output:</p> <blockquote> <p>MB1 in Scientific Notation: 3.88E-4</p> <p>MB1 in Decimal Notation: 0.000388</p> <p>MB2 in Scientific Notation: 3.7002563E-4</p> <p>MB2 in Decimal Notation: 0.0003700256</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload