exponent & expr

Sep 04 2013 | 3:12 pm
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

• Sep 04 2013 | 4:31 pm
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
• Sep 04 2013 | 8:05 pm
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.
• Sep 04 2013 | 10:43 pm
no need to backslash escape the comma anymore these days. it is 2013 after all.
• Sep 05 2013 | 12:33 am
hi
Thanks for your reply and explanation. 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
• Sep 05 2013 | 1:45 am
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
• Sep 05 2013 | 7:14 am
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
• Sep 05 2013 | 8:26 am
oh i am off track. you are on the regexp layer.
well, try to get the exponents as symbols first or something like that?
• Sep 05 2013 | 10:46 am
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...
• Sep 05 2013 | 3:26 pm
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.