Example of cdef function is below.
cdef=a,c,/,b,c,/,b,c,/,*,-,SQRT
How to convert CDEF function to formula.
Moderators: Developers, Moderators
- TheWitness
- Developer
- Posts: 17007
- Joined: Tue May 14, 2002 5:08 pm
- Location: MI, USA
- Contact:
Re: How to convert CDEF function to formula.
First of all, you have to be old enough to know RPN. If you are an engineer, and you used either an HP 11-C or HP 15-C calculator, then you would not be asking that question. Think of an RPN as a first in last out queue. So, to do math, you stack the queue, and then unstack it from the left. So, one good example is:
a,b,*
This would equate to:
result = a * b;
The result is thrown back on the stack. How about this one:
a,b,*,20,/
This would equate to:
result = (a * b ) /20
When there are no more expressions to process, the stack size MUST be 1, if it's one, or if during some calculation there are insufficient elements on the stack, you would get an error. In your case:
a,c,/,b,c,/,b,c,/,*,-,SQRT
result = ( ( ( ( ( a / c ) / b ) / c ) * b ) - c) ^^ 0.5
Which if you ask me, is horribly written. Better to do:
a,c,/,b,/,c,/,b,*,c,-,SQRT
That way you are always dealing with no more than 2 elements on the stack. Easier for old guys like me to read it that way.
Good luck.
a,b,*
This would equate to:
result = a * b;
The result is thrown back on the stack. How about this one:
a,b,*,20,/
This would equate to:
result = (a * b ) /20
When there are no more expressions to process, the stack size MUST be 1, if it's one, or if during some calculation there are insufficient elements on the stack, you would get an error. In your case:
a,c,/,b,c,/,b,c,/,*,-,SQRT
result = ( ( ( ( ( a / c ) / b ) / c ) * b ) - c) ^^ 0.5
Which if you ask me, is horribly written. Better to do:
a,c,/,b,/,c,/,b,*,c,-,SQRT
That way you are always dealing with no more than 2 elements on the stack. Easier for old guys like me to read it that way.
Good luck.
True understanding begins only when we realize how little we truly understand...
Life is an adventure, let yours begin with Cacti!
Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages
For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Life is an adventure, let yours begin with Cacti!
Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages
For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Who is online
Users browsing this forum: No registered users and 0 guests