title: Convert double to int array
body: <p>I have a double </p>
  
  <pre><code>double pi = 3.1415;
  </code></pre>
  
  <p>I want to convert this to a int array</p>
  
  <pre><code>int[] piArray = {3,1,4,1,5};
  </code></pre>
  
  <p>I came up with this</p>
  
  <pre><code>double pi = 3.1415;
  String piString = Double.toString(pi).replace(".", "");
  int[] piArray = new int[piString.length()];
  for (int i = 0; i &lt;= piString.length()-1; i++)
     piArray[i] = piString.charAt(i) - '0'; 
  </code></pre>
  
  <p>It's working but I don't like this solution because I think a lot of conversions between datatypes can lead to errors. Is my code even complete or do I need to check for something else?</p>
  
  <p>And how would you approach this problem?</p>