## exponent & expr

Sep 4, 2013 at 8:12am

# exponent & expr

hi

how to write exponent with expr ???

my operation is like this :
2.04 x 10^(-5) // = 2.04*0.00001 = 0.0000204

o-O

#264236
Sep 4, 2013 at 9:31am

That’d be expr 2.04*pow(10.,-5)

i.e. exponents in expr are written like pow(a,b), as in ‘a’ to the power of ‘b’. Make sure that ‘.’ is after the 10 so that the exponent will be processed as a float.

Hope that helps

#264244
Sep 4, 2013 at 1:05pm

Don’t forget that you have to escape special characters like the comma:

[expr 20.4*pow(10\,-5)]

Note that exponentiation is relatively CPU-costly; if either or both parts of the pow() function are constant, it may be worth the effort of using a precalculated value. There are also some special cases (for instance, non-negative integer exponents) where there are simpler functions you might want to use.

#264287
Sep 4, 2013 at 3:43pm

no need to backslash escape the comma anymore these days. it is 2013 after all.

#264305
Sep 4, 2013 at 5:33pm

hi

In fact I have a big list from ocean sensor, with lot of various number and exponential values…
7.3439156e+005 6.6591366e+000 -8.8263154e-001
7.3439156e+005 6.6961372e+000 -5.6900889e-001
7.3439156e+005 6.6881377e+000 -9.6660798e-001

1st I used “regexp” to “unpack” it
and Now I can make a new list with “real” value… using expr…

best
0-0

#264312
Sep 4, 2013 at 6:45pm

hi

I find a problem on my tree !
I used regexp for “unpack” my value : 7.3439156e+005
if function is positive i have a list : 7.34… e +005
but if function is negative (7.3439156e-005) i find : 7.34… e -5 ( zero disappear ???)

next for formatted exponent (+005) i used a another regexp to have 5.
but with the expression I used -5 become also 5

For expr I need 5 (if positive) and -5 (if negative) ( he don’t like +5)

If you can help me to solve my problem…

o-O

<pre>

– Pasted Max Patch, click to expand. –

</code></pre>

#264316
Sep 5, 2013 at 12:14am

if there occurs something like a*a in your expression, but you also might want negative output, then this expression simsply isnt finished.

a typical situation where one runs into this problem is when using pythagoras to find points in a system.

you will have to split the expression into one “version” for negative and one for positive.

example:

[expr pow(\$f1\,2.) * (\$f1>=0.) + (pow(\$f1\,2.)*-1) * (\$f1<0.)]

#264342
Sep 5, 2013 at 1:26am

oh i am off track. you are on the regexp layer.

well, try to get the exponents as symbols first or something like that?

#264345
Sep 5, 2013 at 3:46am

hi

Yes! I have solve my problem.
I used Jash object “strfilt” & “strcut” to first look if exponent is + or -
then I route it on 2 different way…

I think is not the most efficient, but make what i need…

<pre>

– Pasted Max Patch, click to expand. –

</code></pre>

#264351
Sep 5, 2013 at 8:26am

no need to backslash escape the comma anymore these days

Old habits die hard. Particularly those you’ve been using for over two decades. Leaving out the backslash used to cause tserious tsuris.

#264376

You must be logged in to reply to this topic.