title: How do I convert a double into an n-character string using exponential notation?
body: <p>I have found this vise-versa many times on SO, but never like I want it.</p>
  
  <p>I want to convert a double into a string that takes up <em>exactly</em> n characters.</p>
  
  <p>If n is, for example, 6, then </p>
  
  <p><br>1,000,123.456 would become 1.00E6
  <br>-1,000,123.456 would become 1.0E-6
  <br>1.2345678      would become 1.2345
  <br>1,000,000,000,000 would become 1.0E12</p>
  
  <p>etc.</p>
  
  <p>How do I achieve that?
  Regards,
  Claas M.</p>
  
  <p>P.S How do I set tabs on SO?</p>