Help:ParserFunctions: Difference between revisions

Content deleted Content added
Ed Poor (talk | contribs)
expr: Example: 30 mod 7 = 2
expr: fmt
Line 10:
 
The <tt>expr</tt> function computes mathematical expressions. The supported operators (roughly in order of precedence) are:
{|
 
! Operator
; * : Multiplication
! Operation
; / <span style="font-weight: normal">or</span> div: Division
! Example
; + : Addition
|-
; - : Subtraction (or negation)
! *
; mod : Modulo, gives the remainder of a division
; * :|| Multiplication
:*<nowiki>{{#expr: 30 mod 7}}</nowiki> = {{#expr: 30 mod 7}}
||<nowiki>{{#expr: 30 * 7}}</nowiki> = {{#expr: 30 * 7}}
; round : Rounds off the number on the left to the specified number of digits after the decimal place, given on the right
|-
; = : Equality
;! <>/ <span style="font-weight: normal">or</span> != : Inequalitydiv
|| Division
; < : Less than
||<nowiki>{{#expr: 30 / 7}}</nowiki> = {{#expr: 30 / 7}}
; > : Greater than
|-
; <= : Less than or equal to
! +
; >= : Greater than or equal to
; + :|| Addition
; and : Logical AND
||<nowiki>{{#expr: 30 + 7}}</nowiki> = {{#expr: 30 + 7}}
; or : Logical OR
|-
; not : Logical NOT
! -
; ( ) : Grouping operators
; - :|| Subtraction (or negation)
 
||<nowiki>{{#expr: 30 - 7}}</nowiki> = {{#expr: 30 - 7}}
|-
! mod
; mod :|| Modulo, gives the remainder of a division
:*||<nowiki>{{#expr: 30 mod 7}}</nowiki> = {{#expr: 30 mod 7}}
|-
! round
; round :|| Rounds off the number on the left to the specified number of digits after the decimal place, given on the right
||<nowiki>{{#expr: 30 / 7 round 7}}</nowiki> = {{#expr: 30 / 7 round 7}}
|-
! =
; = :|| Equality
||<nowiki>{{#expr: 30 = 7}}</nowiki> = {{#expr: 30 = 7}}
|-
;! /<> <span style="font-weight: normal">or</span> div: Division!=
|| Inequality
||<nowiki>{{#expr: 30 <> 7}}</nowiki> = {{#expr: 30 <> 7}}
|-
! <
; < :|| Less than
||<nowiki>{{#expr: 30 < 7}}</nowiki> = {{#expr: 30 < 7}}
|-
! >
; > :|| Greater than
||<nowiki>{{#expr: 30 > 7}}</nowiki> = {{#expr: 30 > 7}}
|-
! <=
; <= :|| Less than or equal to
||<nowiki>{{#expr: 30 <= 7}}</nowiki> = {{#expr: 30 <= 7}}
|-
! >=
; >= :|| Greater than or equal to
||<nowiki>{{#expr: 30 >= 7}}</nowiki> = {{#expr: 30 >= 7}}
|-
! and
; and :|| Logical AND
||<nowiki>{{#expr: 30 and 7}}</nowiki> = {{#expr: 30 and 7}}
|-
! or
; or :|| Logical OR
||<nowiki>{{#expr: 30 or 7}}</nowiki> = {{#expr: 30 or 7}}
|-
! not
; not :|| Logical NOT
||<nowiki>{{#expr: not 7}}</nowiki> = {{#expr: not 7}}
|-
! ( )
; ( ) :|| Grouping operators
||<nowiki>{{#expr: (30 + 7) * 7 }}</nowiki> = {{#expr: (30 + 7) * 7 }}
|}
The boolean operators consider 0 to be false and 1 to be true.