<div dir="ltr"><br><div>I'm pretty sure I tried that except with the sprintf ( the examples I found online only had sprint instead of printf ) and no change but I'll definitely try again.</div><div><br></div><div>Thanks</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 24, 2014 at 8:27 AM, Larry Leszczynski <span dir="ltr"><<a href="mailto:larryl@emailplus.org" target="_blank">larryl@emailplus.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Robert -<br>
<br>
On Wed, Jul 23, 2014, at 06:00 PM, Robert L. Harris wrote:<br>
> They are being inserted into a database but the db doesn't recognize that<br>
> as a number. So I have to convert it to -0.00007800825 before the<br>
> insert.<br>
<br>
I think you could just do:<br>
<br>
if ($State =~ /[Ee]/) {<br>
$State = printf "%.12f", $State;<br>
}<br>
<br>
E.g.:<br>
<br>
$ perl -e 'printf "%.12f\n", "-7.7800825E-05"'<br>
-0.000077800825<br>
$ perl -e 'printf "%.12f\n", "-7.7800825e-05"'<br>
-0.000077800825<br>
<br>
<br>
HTH,<br>
Larry<br>
<br>
<br>
><br>
><br>
><br>
> On Wed, Jul 23, 2014 at 2:36 PM, Larry Leszczynski <<a href="mailto:larryl@emailplus.org">larryl@emailplus.org</a>><br>
> wrote:<br>
><br>
> > Hi Robert -<br>
> ><br>
> > > OK, I'm parsing through a bunch of data. Occasionally I get something<br>
> > > like<br>
> > > :<br>
> > > $State="-7.7800825e-05"<br>
> > ><br>
> > > Usually the "e" is capital ( I don't know why this product logs it this<br>
> > > way<br>
> > > ). When the Capital E goes through the if statements below it converts<br>
> > > fine, but the lower case does not it seems...<br>
> > ><br>
> > > I have put in the following sections to convert this:<br>
> > ><br>
> > > $State =~ tr/e/E/;<br>
> > ><br>
> > > if ( $State =~ /E/ ) {<br>
> > > $State2 = sprintf("%.10g", $State);<br>
> > > $State=$State2;<br>
> > > }<br>
> > > if ( $State =~ /e/ ) {<br>
> > > $State2 = sprintf("%.10g", $State);<br>
> > > $State=$State2;<br>
> > > }<br>
> ><br>
> > What are you trying to do with these values? If you use them in numeric<br>
> > context, they work fine as-is, no matter if they have a "e" or "E":<br>
> ><br>
> > $ perl -de 0<br>
> ><br>
> > Loading DB routines from <a href="http://perl5db.pl" target="_blank">perl5db.pl</a> version 1.32<br>
> > Editor support available.<br>
> ><br>
> > Enter h or `h h' for help, or `man perldebug' for more help.<br>
> ><br>
> > main::(-e:1): 0<br>
> > DB<1> print 0 + "-7.7800825e-05"<br>
> > -7.7800825e-05<br>
> > DB<2> print 0 + "-7.7800825E-05"<br>
> > -7.7800825e-05<br>
> ><br>
> ><br>
> > Larry<br>
> > _______________________________________________<br>
> > Denver-pm mailing list<br>
> > <a href="mailto:Denver-pm@pm.org">Denver-pm@pm.org</a><br>
> > <a href="http://mail.pm.org/mailman/listinfo/denver-pm" target="_blank">http://mail.pm.org/mailman/listinfo/denver-pm</a><br>
> ><br>
><br>
><br>
<span class="HOEnZb"><font color="#888888">><br>
> --<br>
> :wq!<br>
> ---------------------------------------------------------------------------<br>
> Robert L. Harris<br>
><br>
> DISCLAIMER:<br>
> These are MY OPINIONS With Dreams To Be A King,<br>
> ALONE. I speak for First One Should Be A Man<br>
> no-one else. - Manowar<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>:wq!<br>---------------------------------------------------------------------------<br>Robert L. Harris<br><br>DISCLAIMER:<br> These are MY OPINIONS With Dreams To Be A King,<br>
ALONE. I speak for First One Should Be A Man<br> no-one else. - Manowar
</div>