[Denver-pm] Scientific Notation -> Dec?????
Robert L. Harris
robert.l.harris at gmail.com
Wed Jul 23 17:00:50 PDT 2014
They are being inserted into a database but the db doesn't recognize that
as a number. So I have to convert it to -0.00007800825 before the insert.
On Wed, Jul 23, 2014 at 2:36 PM, Larry Leszczynski <larryl at emailplus.org>
wrote:
> Hi Robert -
>
> > OK, I'm parsing through a bunch of data. Occasionally I get something
> > like
> > :
> > $State="-7.7800825e-05"
> >
> > Usually the "e" is capital ( I don't know why this product logs it this
> > way
> > ). When the Capital E goes through the if statements below it converts
> > fine, but the lower case does not it seems...
> >
> > I have put in the following sections to convert this:
> >
> > $State =~ tr/e/E/;
> >
> > if ( $State =~ /E/ ) {
> > $State2 = sprintf("%.10g", $State);
> > $State=$State2;
> > }
> > if ( $State =~ /e/ ) {
> > $State2 = sprintf("%.10g", $State);
> > $State=$State2;
> > }
>
> What are you trying to do with these values? If you use them in numeric
> context, they work fine as-is, no matter if they have a "e" or "E":
>
> $ perl -de 0
>
> Loading DB routines from perl5db.pl version 1.32
> Editor support available.
>
> Enter h or `h h' for help, or `man perldebug' for more help.
>
> main::(-e:1): 0
> DB<1> print 0 + "-7.7800825e-05"
> -7.7800825e-05
> DB<2> print 0 + "-7.7800825E-05"
> -7.7800825e-05
>
>
> Larry
> _______________________________________________
> Denver-pm mailing list
> Denver-pm at pm.org
> http://mail.pm.org/mailman/listinfo/denver-pm
>
--
:wq!
---------------------------------------------------------------------------
Robert L. Harris
DISCLAIMER:
These are MY OPINIONS With Dreams To Be A King,
ALONE. I speak for First One Should Be A Man
no-one else. - Manowar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/denver-pm/attachments/20140723/13ed52f9/attachment.html>
More information about the Denver-pm
mailing list