title: Parsing scientific notation sensibly?
body: <p>I want to be able to write a function which receives a number in scientific notation as a string and splits out of it the coefficient and the exponent as separate items. I could just use a regular expression, but the incoming number may not be normalised and I'd prefer to be able to normalise and then break the parts out.</p>
  
  <p>A colleague has got part way of an solution using VB6 but it's not quite there, as the transcript below shows.</p>
  
  <pre><code>cliVe&gt; a = 1e6
  cliVe&gt; ? "coeff: " &amp; o.spt(a) &amp; " exponent: " &amp; o.ept(a)
  coeff: 10 exponent: 5 
  </code></pre>
  
  <p><em>should have been 1 and 6</em></p>
  
  <pre><code>cliVe&gt; a = 1.1e6
  cliVe&gt; ? "coeff: " &amp; o.spt(a) &amp; " exponent: " &amp; o.ept(a)
  coeff: 1.1 exponent: 6
  </code></pre>
  
  <p><em>correct</em></p>
  
  <pre><code>cliVe&gt; a = 123345.6e-7
  cliVe&gt; ? "coeff: " &amp; o.spt(a) &amp; " exponent: " &amp; o.ept(a)
  coeff: 1.233456 exponent: -2
  </code></pre>
  
  <p><em>correct</em></p>
  
  <pre><code>cliVe&gt; a = -123345.6e-7
  cliVe&gt; ? "coeff: " &amp; o.spt(a) &amp; " exponent: " &amp; o.ept(a)
  coeff: 1.233456 exponent: -2
  </code></pre>
  
  <p><em>should be -1.233456 and -2</em></p>
  
  <pre><code>cliVe&gt; a = -123345.6e+7
  cliVe&gt; ? "coeff: " &amp; o.spt(a) &amp; " exponent: " &amp; o.ept(a)
  coeff: 1.233456 exponent: 12
  </code></pre>
  
  <p><em>correct</em></p>
  
  <p>Any ideas? By the way, Clive is a CLI based on VBScript and can be found on my <a href="http://codeaholic.blogspot.com" rel="noreferrer">weblog</a>.</p>