Rounding issue in Java
<p>I'm trying to do a quick 2 vars equation solver using Cramer's rule
but for some reason java keeps on rounding my answers so i don't get the right answer.</p>

<p>the basic rule for getting single answer is </p>

<pre><code>((a11*a22)-(a12*a21))!=0) 
</code></pre>

<p>and the solution should be</p>

<pre><code>double sol1 = (b1*a22-b2*a12) / (a11*a22-a12*a21);
double sol2 = (b2*a11-b1*a21) / (a11*a22-a12*a21);
</code></pre>

<p>but for some reason i get -4.0 and 4.0 instead of -4.0 and 4.5 for 1,2,3,4,5,6</p>

<p>that's the problematic code if it helps:</p>

<pre><code>if (((a11*a22)-(a12*a21))!=0) {
   double sol1 = (b1*a22-b2*a12) / (a11*a22-a12*a21);
   double sol2 = (b2*a11-b1*a21) / (a11*a22-a12*a21);
   System.out.println("Single solution: ("+sol1+", "+sol2 +")");
 }
</code></pre>
