Infix Math: Difference between revisions

From Compost Wiki
Jump to navigation Jump to search
Dannym (talk | contribs)
Created page with "==Infix Math== Infix Math, which Compost4 now supports, is the common arithmetic and logical formula notation, in which operators are written infix-style between the operands..."
 
Dannym (talk | contribs)
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Infix Math==
==Infix Math==
 
{{Description|description= Infix Math, which Compost4 now supports, is the common arithmetic and logical formula notation, in which operators are written infix-style between the operands they act on (e.g. 2 + 2 instead of ADD# 2 2). }}
Infix Math, which Compost4 now supports, is the common arithmetic and logical formula notation, in which operators are written infix-style between the operands they act on (e.g. 2 + 2 instead of ADD# 2 2).




Line 11: Line 10:
:"/" [[DIV#]] <br>
:"/" [[DIV#]] <br>
:"%" [[MOD#]] <br>
:"%" [[MOD#]] <br>
Supported infix comparator operators:
:"==" [[Equal?]] <br>
:"==" [[Equal?]] <br>
:"!=" [[NotEqual?]] <br>
:"!=" [[NotEqual?]] <br>
Line 18: Line 20:
:">" [[GreaterThan?]] <br>
:">" [[GreaterThan?]] <br>


'''NOTE'''
==Notes==
 
Please do note that Compost4 currently is unaware of the proper order of operations, so if you write "1 + 2 * 3" you will get 9 (from MUL# ADD# 1 2 3).  However, DO NOT rely on the current left-to-right evaluation order for infix operations. At some point we will pick up order of operations, and you don't want your posts to suddenly change results.
Please do note that Compost4 currently is unaware of the proper order of operations, so if you write "1 + 2 * 3" you will get 9 (from MUL# ADD# 1 2 3).  However, DO NOT rely on the current left-to-right evaluation order for infix operations. At some point we will pick up order of operations, and you don't want your posts to suddenly change results.



Latest revision as of 18:15, 10 December 2014

Infix Math

Description

Infix Math, which Compost4 now supports, is the common arithmetic and logical formula notation, in which operators are written infix-style between the operands they act on (e.g. 2 + 2 instead of ADD# 2 2).


Supported infix operators:

"+" ADD#
"-" SUB#
"*" MUL#
"/" DIV#
"%" MOD#

Supported infix comparator operators:

"==" Equal?
"!=" NotEqual?
"<=" LTEqual?
">=" GTEqual?
"<" LessThan?
">" GreaterThan?

Notes

Please do note that Compost4 currently is unaware of the proper order of operations, so if you write "1 + 2 * 3" you will get 9 (from MUL# ADD# 1 2 3). However, DO NOT rely on the current left-to-right evaluation order for infix operations. At some point we will pick up order of operations, and you don't want your posts to suddenly change results.

I recommend liberal use of parentheses: "1 + (2 * 3)" will correctly output 7 (from ADD# 1 MUL# 2 3).