[Denver-pm] Scientific Notation -> Dec?????

Robert L. Harris robert.l.harris at gmail.com
Fri Jul 25 07:17:03 PDT 2014


OK,
  That looks like it did it.

Robert



On Thu, Jul 24, 2014 at 9:25 AM, Larry Leszczynski <larryl at emailplus.org>
wrote:

> Oops, sorry - that should be sprintf, not printf:
>
> if ($State =~ /[Ee]/) {
>     $State = sprintf "%.12f", $State;
> }
>
>
> On Thu, Jul 24, 2014, at 09:17 AM, Robert L. Harris wrote:
> > 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.
> >
> > Thanks
> >
> >
> > On Thu, Jul 24, 2014 at 8:27 AM, Larry Leszczynski <larryl at emailplus.org
> >
> > wrote:
> >
> > > Hi Robert -
> > >
> > > On Wed, Jul 23, 2014, at 06:00 PM, Robert L. Harris wrote:
> > > > 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.
> > >
> > > I think you could just do:
> > >
> > > if ($State =~ /[Ee]/) {
> > >     $State = printf "%.12f", $State;
> > > }
> > >
> > > E.g.:
> > >
> > > $ perl -e 'printf "%.12f\n", "-7.7800825E-05"'
> > > -0.000077800825
> > > $ perl -e 'printf "%.12f\n", "-7.7800825e-05"'
> > > -0.000077800825
> > >
> > >
> > > HTH,
> > > Larry
> > >
> > >
> > > >
> > > >
> > > >
> > > > 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
> > >
> >
> >
> >
> > --
> > :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
>



-- 
: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/20140725/a749ee70/attachment.html>


More information about the Denver-pm mailing list