Help:ParserFunctions: Difference between revisions
Content deleted Content added
→expr: Example: 30 mod 7 = 2 |
PhilBoswell (talk | contribs) →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▼
:*<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▼
|| Division
; < : Less than▼
||<nowiki>{{#expr: 30 / 7}}</nowiki> = {{#expr: 30 / 7}}
; > : Greater than▼
|-
; <= : Less than or equal to▼
! +
; >= : Greater than or equal to▼
; and : Logical AND▼
||<nowiki>{{#expr: 30 + 7}}</nowiki> = {{#expr: 30 + 7}}
; or : Logical OR▼
|-
; not : Logical NOT▼
! -
; ( ) : Grouping operators▼
||<nowiki>{{#expr: 30 - 7}}</nowiki> = {{#expr: 30 - 7}}
|-
! mod
|-
! round
▲
||<nowiki>{{#expr: 30 / 7 round 7}}</nowiki> = {{#expr: 30 / 7 round 7}}
|-
! =
||<nowiki>{{#expr: 30 = 7}}</nowiki> = {{#expr: 30 = 7}}
|-
|| Inequality
||<nowiki>{{#expr: 30 <> 7}}</nowiki> = {{#expr: 30 <> 7}}
|-
! <
||<nowiki>{{#expr: 30 < 7}}</nowiki> = {{#expr: 30 < 7}}
|-
! >
||<nowiki>{{#expr: 30 > 7}}</nowiki> = {{#expr: 30 > 7}}
|-
! <=
||<nowiki>{{#expr: 30 <= 7}}</nowiki> = {{#expr: 30 <= 7}}
|-
! >=
||<nowiki>{{#expr: 30 >= 7}}</nowiki> = {{#expr: 30 >= 7}}
|-
! and
||<nowiki>{{#expr: 30 and 7}}</nowiki> = {{#expr: 30 and 7}}
|-
! or
||<nowiki>{{#expr: 30 or 7}}</nowiki> = {{#expr: 30 or 7}}
|-
! not
||<nowiki>{{#expr: not 7}}</nowiki> = {{#expr: not 7}}
|-
! ( )
||<nowiki>{{#expr: (30 + 7) * 7 }}</nowiki> = {{#expr: (30 + 7) * 7 }}
|}
The boolean operators consider 0 to be false and 1 to be true.
|