I wrote the following code...
public class MatrixAddition
{
    public static void main(String[] args)
    {
        double matrix[][] = { { 1.2, 3.3, 1.2 }, { 1.0, 2.2, 4.5 }, { 1.3, 4.5, 2.2 } };
        double matrix1[][] = { { 2.2, -3.3, 1.1 }, { 7.0, -2.2, 4.2 }, { 2.2, 0.0, 0.3 } };
        double result[][] = new double[matrix.length][matrix1.length];
        for(int iResult = 0; iResult < result.length; iResult++) {
            for(int jResult = 0; jResult < result[iResult].length; jResult++) {
                result[iResult][jResult] = matrix[iResult][jResult] + matrix1[iResult][jResult];
                System.out.print(result[iResult][jResult] + " ");
            }
            System.out.print("\n");
        }
    }
}
The result is:
3.4000000000000004 0.0 2.3
8.0 0.0 8.7 
3.5 4.5 2.5 
Every time when i change the values for Matrix[i0][j0] and Matrix1[i0][j0] i get proper results, but when the values are 1.2 and 2.2 i always get 3.400000000000004. How can i fix that , and why that happens.
Thanks in advance.
 
     
     
     
    