Dividing Long with Double in Java producing wrong results : <p>I am trying to divide a <code>Long</code> in Java with a percentage like <code>0.99</code> and it keeps giving me crazy results.</p>

<pre><code>long totalBytes = 5877062
long final = (long) (totalBytes / 0.99) // IT PRODUCES 5936426 &gt; totalBytes
</code></pre>

<p><a href="https://i.stack.imgur.com/ImfS9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ImfS9.png" alt="enter image description here"></a></p>

<p>what am i doing wrong ? For <code>1.00</code> it works well , if i give <code>0.95 ++</code> it always produces something bigger than the <code>totalBytes</code>.</p>

<p>Why am i loosing precision ?</p>

<p><code>Java Version 10.0.2</code></p>
