Power of number (pow) calculation in rules
Moderators: grovkillen, Stuntteam, TD-er
Power of number (pow) calculation in rules
I was wondering if it is possible to calculate the power of a number in rules.
E.g. 2^x
E.g. 2^x
Re: Power of number (pow) calculation in rules
I was like, OK, quickly show the link in the docs and be done with it...
Like this link: https://espeasy.readthedocs.io/en/lates ... -functions
But on closer inspection, it doesn't mention the pow function.
However it does exist and is exactly what you'd expect
(see case '^')
Like this link: https://espeasy.readthedocs.io/en/lates ... -functions
But on closer inspection, it doesn't mention the pow function.
However it does exist and is exactly what you'd expect
Code: Select all
double RulesCalculate_t::apply_operator(char op, double first, double second)
{
switch (op)
{
case '+':
return first + second;
case '-':
return first - second;
case '*':
return first * second;
case '/':
return first / second;
case '%':
return static_cast<int>(round(first)) % static_cast<int>(round(second));
case '^':
return pow(first, second);
default:
return 0.0;
}
}
Re: Power of number (pow) calculation in rules
I knew i read about this somewhere... and was actually surprised that nothing came up in the documentation.
Re: Power of number (pow) calculation in rules
I think these basic functions should be mentioned in that "Basic Math Functions" section too.
Re: Power of number (pow) calculation in rules
Looking forward to the pull request then
Re: Power of number (pow) calculation in rules
of course... i am especially good at that...
I have never really dared to do it, because I find the editing a bit hard to get used to. Do you use an extra editor for that or do you edit it directly in the code editor?
I have never really dared to do it, because I find the editing a bit hard to get used to. Do you use an extra editor for that or do you edit it directly in the code editor?
Re: Power of number (pow) calculation in rules
I just edit it in VS code.
Just open the CLI in VS code, so you're in the same Python virtual env as used to run PlatformIO.
Then go to docs folder and run ./make.bat html (or the make html variant when not on Windows)
If you're missing Python packages, run (from the docs folder)
Just open the CLI in VS code, so you're in the same Python virtual env as used to run PlatformIO.
Then go to docs folder and run ./make.bat html (or the make html variant when not on Windows)
If you're missing Python packages, run (from the docs folder)
Code: Select all
pip3 install -r requirements.txt
Re: Power of number (pow) calculation in rules
I knew that this wouldn´t be as easy as it looked..
after reading a lot, adding paths and packages, reading a bit more, installing sphinx manually i finally got something when typing "make html"....
...error messages
so...a few times installing, reading, reinstalling later i finally got to the point where it "makes" something...
so it only took me almost 2 hours to actually start with the content....
...but now i´ll make myself a coffee and relax...
...maybe I will also treat myself to a cookie...
...or two...
ps: i guess i can ignore these error messages?
after reading a lot, adding paths and packages, reading a bit more, installing sphinx manually i finally got something when typing "make html"....
...error messages
so...a few times installing, reading, reinstalling later i finally got to the point where it "makes" something...
so it only took me almost 2 hours to actually start with the content....
...but now i´ll make myself a coffee and relax...
...maybe I will also treat myself to a cookie...
...or two...
ps: i guess i can ignore these error messages?
Code: Select all
reading sources... [100%] index
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index
source/Plugin/AdaGFX_commands.repl:45: WARNING: undefined label: p123_page
source/Plugin/AdaGFX_values.repl:6: WARNING: undefined label: p096_page
source/Plugin/AdaGFX_commands.repl:45: WARNING: undefined label: p123_page
source/Plugin/AdaGFX_commands.repl:45: WARNING: undefined label: p123_page
source/Plugin/AdaGFX_commands.repl:45: WARNING: undefined label: p123_page
source/Plugin/AdaGFX_values.repl:6: WARNING: undefined label: p096_page
source/Plugin/AdaGFX_commands.repl:45: WARNING: undefined label: p123_page
generating indices... genindex done
writing additional pages... search done
copying images... [100%] Tools/images/SettingsArchive_provisioning.png
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded, 7 warnings.
Re: Power of number (pow) calculation in rules
Most of those warnings will be fixed once P123 is merged into mega, but that's not yet completed. Can be ignored for now.
/Ton (PayPal.me)
Who is online
Users browsing this forum: No registered users and 1 guest