title: new Float("0.333") converts my 0.333 0.333+(14 more decimal places)
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7581741/floating-point-error-in-representation">Floating point error in representation?</a>  </p>
  </blockquote>
  
  
  
  <p>So I am running this code to read float string values from a a file and store the values in to an array. When the program reads in "0.333" from the file it creates a new float value but the value is converted into 0.33329999446868896! Why is this? And how can I fix this issue? The matrices are declared as follows:</p>
  
  <pre><code>this.matrix = new double[this.getRow()][this.getCol()];
  this.bMatrix = new double[this.getRow()];  
  
  try {
          // make sure no blank lines at the end of the file.
          for (int i = 0; (strLine = reader.readLine()) != null; i++) {  
              System.out.println("Line from file #" + i + " " + strLine);
              String[] columns = strLine.trim().split("\\s+");
              for (int j = 0; j &lt; columns.length; j++) {
                  if (j &lt; (columns.length - 1)) {
                      //A-matrix
                      this.matrix[i][j] = new Float(columns[j]).floatValue();
                      System.out.println("Element added to A-matrix: " + columns[j]);
                  } else {
                      // B-matrix
                      bMatrix[i] = new Float(columns[j]).floatValue();
                      System.out.println("Element added to B-matrix: " + columns[j]);
  
                  }
              }
          }
          showMatrix();
      } catch (IOException | NumberFormatException e) {
          reader.close();
  
      }
  }
  </code></pre>
  
  <p>Thanks for any assistance.</p>