Page 1 of 1

Subtraction of negative numbers using {math+...}

Posted: Sun Dec 28, 2008 7:33 pm
by skyewright
On a html template I use the mathPLUS facility to work out the difference between 2 temp sensors.

<aside>
mathPLUS is not really written like that, but if I try to write it correctly, Joomla seems to 'eat' the plus sign, so where you see mathPLUS just imagine that it's math followed by a plus sign!
</aside>

For several months I've been using:

{mathPLUS -[actual_th0_temp_c] [actual_t8_temp_c]}

Last night I noticed that the calculation was failing. The problem seemed to be that actual_th0_temp_c was negative.

Today I tried to get around that by replacing the simple negative prefix with a nested math*, i.e.:

{mathPLUS {math* -1.0 [actual_th0_temp_c]} [actual_t8_temp_c]}

but that doesn't seem to work at all.

Am I missing something obvious?

Re:Subtraction of negative numbers using {math+...}

Posted: Sun Dec 28, 2008 8:11 pm
by admin
Meteohub's math parsing is very basic, it does not allow for nested formulas. I will introduce a "math-" to fix this. I have not thought of negative numbers, when suggesting the "-" prefix.

Re:Subtraction of negative numbers using {math+...}

Posted: Sun Dec 28, 2008 11:35 pm
by skyewright
admin wrote:I will introduce a "math-"
Thank you. :cheer:

Re:Subtraction of negative numbers using {math+...}

Posted: Sun Dec 28, 2008 11:45 pm
by skyewright
Afterthought...

What if math+ just looked out for, and stripped any doubled minus signs? e.g. --0.5 gets processed as 0.5, which is what it effectively is?

Just a thought. If math- seems a better idea to you, that's fine by me.

PS. It seems that it is only the 'Preview' that 'eats' the plus signs! :)