Scientific Notation in Calculation (error)

50 views
Skip to first unread message

MJ1972

unread,
Oct 25, 2021, 5:00:01 PM10/25/21
to Tasker
I've got a bunch of lookups to an API for crypto currency prices. Most of these are working, but one (SHIB) is giving problems, I'm assuming because it has such a small value per coin.

The figure I'm working with is from https://min-api.cryptocompare.com/data/price?fsym=SHIB&tsyms=GBP (currently 0.00003003).

That value is so small, and typically I want to multiply that by thousands, or even millions, but the error Tasker throws is something like: -

Expr mathEval: round(xxxxxx*2.816e-05*100)/100: dsv/Variable Set/round(%MYSHIBTOTAL*%shibprice*100)/100: Mathematical expression contains the invalid value "2.816e" at offset 15 in expression "round(xxxxxx*2.816e-05*100)/100"

xxxxxx is the value I'm multiplying by, the 2.816e-05 is what tasker is using for the returned value - I need this not to be converted to scientific notation.

Any ideas / workarounds?

jmjc...@gmail.com

unread,
Oct 25, 2021, 10:01:58 PM10/25/21
to Tasker
Assume %num has the value of "2.816e-05"

Use a Variable Search Replace action to replace "e" with "*10^"

Variable Search Replace:
Variable: %num
Search: e
Replace Matches: check
Replace With: *10^

Then %num will become "2.816*10^-05" and will work in a Do Math action.

MJ1972

unread,
Oct 26, 2021, 9:52:46 AM10/26/21
to Tasker
That worked... thanks again!
Reply all
Reply to author
Forward
0 new messages