Jump to content

Help:Conditional expressions

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 1.47.155.64 (talk) at 16:06, 14 March 2023. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

This page describes how to use various parser functions to display different results based on detected conditions in a page or template.

Here is a quick summary of these functions in terms of how they treat their input (the function names are linked to more detailed descriptions of them found below on this page):

  • #if checks the truth value of a string
  • #ifeq checks whether two strings or numbers are equal
  • #switch compares a string to a set of possible values
  • #expr evaluates a mathematical expression
  • #ifexpr evaluates a mathematical expression and acts on the truth value of the result
  • #iferror checks whether a string (often an expression inside of #expr) triggers a parser error
  • #ifexist checks whether a page with a given title exists on the wiki (including image/media files)

For the use of these functions in tables, see Help:Conditional tables.

Summary

The basic syntax (and use) of each function is as follows:

  • {{#if: test string | value if true | value if false }}
    (selects one of two values based on whether the test string is true or false
  • {{#ifeq: string 1 | string 2 | value if equal | value if unequal }}
    (selects one of two values based on whether the two strings are equal—a numerical comparison is done whenever that is possible)
  • {{#switch: test string | case1 = value for case 1 | ... | default }}
    (chooses between multiple alternatives based on the value of the test string—basically equivalent to a chain of #ifeq tests, but much more efficient)
  • {{#expr: expression }}
    (evaluates a given expression; see Help:Calculation for details)
  • {{#ifexpr: expression | value if true | value if false }}
    (selects one of two values based on the truth value of an evaluated expression)
  • {{#iferror: test string | value if error | value if no error }}
    (selects one of two values based on whether the test string generates a parser error)
  • {{#ifexist: page title | value if exists | value if doesn't exist }}
    (selects one of two values depending on the existence of a page having the given title)

Note that "truth" is interpreted very differently by the string-based #if function and the numerically oriented functions #expr and #ifexpr. A string is considered true if it contains at least one non-whitespace character (thus, for example, the #if function interprets the strings "0" and "FALSE" as true values, not false). Any string containing only whitespace or no characters at all will be treated as false (thus #if interprets " " and "", as well as undefined parameters, as false values). On the other hand, in the expressions evaluated by #expr and #ifexpr, Boolean operators like and, or, and not interpret the numerical value 0 as false and any other number as true. In terms of output, Boolean operations return 1 for a true value and 0 for false (and these are treated as ordinary numbers by the numerical operators). Non-numerical strings (including most uses of empty strings and undefined parameters) will cause #expr and #ifexpr to report an error.

Also note that all leading and trailing whitespace within each of the parts of a parser function call gets stripped out, allowing the calls to be formatted with extra whitespace for better readability. For example:

{{#if: {{{xx|}}}
   | parameter xx value is true
   | parameter xx value is false
}}

Here, only the spaces in the strings "parameter xx value is true" and "parameter xx value is true" are significant. All other whitespace is ignored. Thus, the construct above is equivalent to the following call:

{{#if:{{{xx|}}}|parameter xx value is true|parameter xx value is false}}

In any part of a parser function call where a string is expected, one can use a literal string, a template call, a parser function call, or some other magic word.

Using #if

See also: the {{if}} template

The #if function selects one of two alternatives based on the truth value of a test string.

{{#if: test string | value if true | value if false }}

As explained above, a string is considered true if it contains at least one non-whitespace character. Any string containing only whitespace or no characters at all will be treated as false.

Undefined parameter values are tricky: if the first positional parameter was not defined in the template call, then {{{1}}} will evaluate to the literal string "{{{1}}}" (i.e., the 7-character string containing three sets of curly braces around the number 1), which is a true value. (This problem exists for both named and positional parameters.) But {{{1|}}} will evaluate to the empty string (a false value) because the vertical bar or pipe character, "|", immediately following the parameter name specifies a default value (here an empty string because there is nothing between the pipe and the first closing curly brace) as a "fallback" value to be used if the parameter is undefined.

This function can be used to check whether a parameter has been passed to a template with a true value.

Examples:

{{#if: {{{1|}}}
   | first positional parameter has a true value
   | first positional parameter has a false value (or no value)
}}

{{#if: {{{xx|}}}
   | named parameter xx has a true value
   | named parameter xx has a false value (or no value)
}}

{{#if: {{{xx|}}}{{{yy|}}}
   | either xx or yy has a true value, or both are true
   | both xx and yy have a false value (or no value)
}}

Testing whether both of two parameters are true requires a little more effort. For example:

{{#if: {{{xx|}}}
   | {{#if: {{{yy|}}}
       | both xx and yy have true values
       | xx is true but not yy
     }}
   | both xx and yy are false
}}

Note that nesting #if functions like this gets very resource-intensive very fast. On some wikis, even seven levels of nesting might exceed resource limits.

See the discussion of #ifeq for how to detect whether a parameter has been defined regardless of whether its value is true or false.

Using #ifeq

See also: the {{ifeq}} template

The #ifeq function selects one of two alternatives based on whether two test strings are equal to each other.

{{#ifeq: string 1 | string 2 | value if equal | value if not equal }}

If both strings are valid numerical values, they are compared as numbers, rather than as literal strings:

{{#ifeq: 01 | 1 | equal | not equal }}equal
{{#ifeq: x01 | x1 | equal | not equal }}not equal
{{#ifeq: 2.000 | 002 | equal | not equal }}equal
{{#ifeq: 2.5 | 2+.5 | equal | not equal }}not equal (arithmetic!)
{{#ifeq: 2*10^3 | 2000 | equal | not equal }}not equal (arithmetic!)
{{#ifeq: 2E3 | 2000 | equal | not equal }}equal

As seen in the 4th and 5th examples, mathematical expressions are not evaluated. They are treated as regular strings. But #expr can be used to evaluate such expressions.

{{#ifeq: {{#expr:2*10^3}} | 2000 | equal | not equal }}equal

String comparisons are case-sensitive:

{{#ifeq: King | king | equal | not equal }}not equal

For case-insensitive checking, use the {{lc:}} or {{uc:}} function to force the strings to all lower- or upper-case. This is most useful when dealing with parameter values:

{{#ifeq: {{lc:King}} | king | equal | not equal }}equal
{{#ifeq: {{lc: {{{position}}} }} | top | code if true | code if false }}

In the second example, the values "top", "Top", and "TOP" will all result in successful matches.

This parser function can be used to detect whether a template parameter is defined, even if it has been set to a false value. For example, to check whether the first positional parameter has been passed to a template (note that the strings "+" and "-" can be any two different non-whitespace strings):

{{#ifeq: {{{1|+}}} | {{{1|-}}} | 1 is defined | 1 is undefined }}

To be specific, here's what this code generates when called in the following ways:

{{template-name}}1 is undefined
{{template-name|}}1 is defined
{{template-name|1=}}1 is defined
{{template-name|1=foo}}1 is defined

See mw:Help:Extension:ParserFunctions##ifeq for more details, including possible counterintuitive results due to the way this function is implemented.

Using #switch

The #switch function selects between multiple alternatives based on an input string.

{{#switch: test string | case1 = value for case 1 | ... | default value }}

Equivalent to the switch statement found in some programming laguages, it is a convenient way of dealing with multiple cases without having to chain lots of #if functions together. However, note that performance suffers when there are more than 100 alternatives. Placing common values earlier in the list of cases can cause the function to execute significantly faster.

For each case, either side of the equals sign "=" can be a simple string, a call to a parser function (including #expr to evaulate expressions), or a template call. If any cases are not associated with a value (i.e., no equals sign is used), the next specified value will be used. This allows multiple cases to share the same value without having to specify that value repeatedly (as seen in the example below).

If no matching case is found, then the default value is used. This is usually specified last with no associated "case" value, as seen in the syntax summary above, but it can also be specified at any point after the test string if the construct | #default = value is used (see the second example below). If no default is specified in either way, then a null string will be returned when no cases match the input string.

This function in particular benefits from being set up in a multiline format.

{{#switch: {{{x|}}}
 | 1 = one
 | 2 = two
 | 3 = three
 | 4 = four
 | 5
 | 6
 | 7 = in the range 5 to 7
 | other
}}

Here, if the value of the template parameter x is the string "1", then the output will be the string "one"; if "2", then "two"; and so forth. But for any of the values "5", "6" or "7", the output will be the string "in the range 5 to 7". For any other value, or a null value, it will return the string "other".

The following example is equivalent to the previous one:

{{#switch: {{{x|}}}
 | #default = other
 | 1 = one
 | 2 = two
 | 3 = three
 | 4 = four
 | 5|6|7 = in the range 5 to 7
}}

See Help:Switch parser function for a full description and more examples.

Using #expr

The #expr function evaluates mathematical (including Boolean) expressions. While not itself a conditional function, it is often used inside of those functions, so it is briefly described here. See m:Help:Calculation for further details.

{{#expr: expression }}

Unlike the #if function, all values in the expression evaluated by #expr are assumed to be numerical. It does not work with arbitrary strings. For the purpose of its Boolean operations (e.g., and, or, and not), false is represented by 0 and true by 1; these values are treated as regular numbers by the numerical operators. As input, the Boolean operators treat 0 as false and every other number as true. If any non-numerical strings are used, an error will result.

Examples:

{{#expr: ( {{{1}}}+{{{xshift}}} - 6 ) * 18.4 }}
{{#expr: ln(7)^3 - abs(-0.344) + floor(5/3) round 3 }}
{{#expr: {{{n}}}>0 and {{{n}}}<1.0 }}

Note that these examples assume that all parameters referred to are defined and have numerical values. If this is not the case, errors will occur. See #iferror for one way to handle errors.

Using #iferror

The #iferror function selects one of two alternatives depending on whether its input triggers an error.

{{#iferror: test string | value if error | value if correct }}

The test string is typically a call to #expr or some other parser function, but can be plain text or a template call, in which case an error would be triggered by any HTML object with class="error" or any of various template errors such as loops and recursions, or some other "failsoft" parser error.

One or both of the return values can be omitted. If the value if correct is omitted, the test string is returned if it is not erroneous. If the value if error is also omitted, an empty string is returned on an error:

{{#iferror: {{#expr: 1 + 2 }} | error | correct }}correct
{{#iferror: {{#expr: 1 + X }} | error | correct }}error
{{#iferror: {{#expr: 1 + 2 }} | error }}3
{{#iferror: {{#expr: 1 + X }} | error }}error
{{#iferror: {{#expr: 1 + 2 }} }}3
{{#iferror: {{#expr: 1 + X }} }}
{{#iferror: {{#expr: . }} | error | correct }}correct
{{#iferror: <strong class="error">a</strong> | error | correct }}error

Using #ifexist

The #ifexist function selects one of two alternatives depending on whether a page exists at the specified title.

{{#ifexist: page title | value if page exists | value if page doesn't exist }}

The page can be in any namespace, so it can be an article or "content page", an image or other media file, a category, etc. The actual content of the page is irrelevant, so it may be empty or a redirect. Titles that would result in redlinks do not exist (and, as with redlinks, checking for the existence of a nonexistent page causes the title to appear on Special:WantedPages).

The checking is extremely fast, but has been limited to 500 instances per page because it is considered an "expensive parser function". (However, multiple checks of the same title on the same page do not count as multiple instances, because the results of the first check is cached and reused for the subsequent checks.)

Checking for template parameters

A common idiom encountered in template coding is the "chain of fallback values", as seen in this example:

Here, if the first positional parameter is defined, then its value will be used. If it is undefined, then the parameter named url will be checked and if it is defined, then its value will be used. If both the first positional parameter and url are undefined, then the parameter named URL is checked: if it is defined, its value is used; if not, then the empty string will be used.

The problem is, this construct tends to be interpreted as being equivalent to:

<

and it is not. The difference is that the first construct, using default values, depends on the definedness of the parameters, whereas the second construct, using remove functions, depends on the truth value of the parameters. These are two very different things.

If any of the parameters in the chain of fallback values (in the first construct) have been set to an empty value (or only whitespace) in the template call, then that empty value will be used instead of "falling back" to the next parameter in the chain. So, for example, if the template is called in either of these two ways:

{{template-name||url=//example.com/}}
{{template-name|url=///|}}

The first positional parameter has been defined: its value is the empty string. Thus, the value of url is irrelevant. The template never "gets to" that value.

Similarly, if the template is called in this way:

{{template-name|url=|URL=//example.com/}}

The empty value of url will be used instead of the value of URL.

These examples might seem a bit contrived, since they rely on the template being called in "the wrong way". But it is surprisingly easy to run across cases where these problems occur with perfectly reasonable template calls (especially if there is a "hierarchy" of templates, where one template calls another, passing on the values of its parameters to the parameters of the "lower-level" template—in such cases, one will often end up with defined-but-empty parameter values).

Because of issues like this, template coders sometimes find themselves needing to distinguish between different combinations of three states: defined-and-true, defined-and-false, and undefined. This can be done in the following ways (the first positional parameter is used here, but named parameters work the same way).

Defined-and-true   vs.   undefined or defined-and-false

{{: {{{1|}}} | 1 is defined and contains non-whitespace | 1 is undefined, empty, or contains only whitespace }}

Defined (whether true or false)   vs.   undefined

{{: {{{1|+}}} | {{{1|-}}} | 1 is defined (and possibly empty or only-whitespace) | 1 is undefined }}

Note that the + and - characters can be any two different non-whitespace characters. Also, if you just want to use the value of the parameter when it's defined and some other value when it's undefined, you can use the simpler "fallback" construct:

{{{1|some other value}}}

Defined-and-true   vs.   defined-and-false   vs.   undefined

<remove>

+ −
Plus and minus signs
In UnicodeU+002B + PLUS SIGN (&plus;)
U+2212 MINUS SIGN (&minus;)
Different from
Different fromU+002D - HYPHEN-MINUS
U+2010 HYPHEN
(many) – Dash
Related
See alsoU+00B1 ± PLUS-MINUS SIGN
U+2213 MINUS-OR-PLUS SIGN

The plus sign (+) and the minus sign () are mathematical symbols used to denote positive and negative functions, respectively. In addition, the symbol + represents the operation of addition, which results in a sum, while the symbol represents subtraction, resulting in a difference.[1] Their use has been extended to many other meanings, more or less analogous. Plus and minus are Latin terms meaning 'more' and 'less', respectively.

The forms + and are used in many countries around the world. Other designs include U+FB29 HEBREW LETTER ALTERNATIVE PLUS SIGN for plus and U+2052 COMMERCIAL MINUS SIGN for minus.

History

Though the signs now seem as familiar as the alphabet or the Arabic numerals, they are not of great antiquity. The Egyptian hieroglyphic sign for addition, for example, resembles a pair of legs walking in the direction in which the text was written (Egyptian could be written either from right to left or left to right), with the reverse sign indicating subtraction:[2]

D54
or
D55

Nicole Oresme's manuscripts from the 14th century show what may be one of the earliest uses of + as a sign for plus.[3]

In early 15th century Europe, the letters "P" and "M" were generally used.[4][5] The symbols (P with overline, , for più (more), i.e., plus, and M with overline, , for meno (less), i.e., minus) appeared for the first time in Luca Pacioli's mathematics compendium, Summa de arithmetica, geometria, proportioni et proportionalità, first printed and published in Venice in 1494.[6]

The + sign is a simplification of the Latin: et (comparable to the evolution of the ampersand &).[7] The may be derived from a macron ◌̄ written over ⟨m⟩ when used to indicate subtraction; or it may come from a shorthand version of the letter ⟨m⟩ itself.[8]

A page from Johannes Widmann's book
From Johannes Widmann's book on "handy and pretty arithmetic for all merchants"[9][10]

In his 1489 treatise, Johannes Widmann referred to the symbols and + as minus and mer (Modern German mehr; "more"): "[...] was − ist das ist minus [...] und das + das ist mer das zu addirst".[9][10][11] They were not used for addition and subtraction in the treatise, but were used to indicate surplus and deficit; usage in the modern sense is attested in a 1518 book by Henricus Grammateus.[12][13]

Robert Recorde, the designer of the equals sign, introduced plus and minus to Britain in 1557 in The Whetstone of Witte:[14] "There be other 2 signes in often use of which the first is made thus + and betokeneth more: the other is thus made − and betokeneth lesse."

Plus sign

The plus sign (+) is a binary operator that indicates addition, as in 2 + 3 = 5. It can also serve as a unary operator that leaves its operand unchanged (+x means the same as x). This notation may be used when it is desired to emphasize the positiveness of a number, especially in contrast with the negative numbers (+5 versus −5).

The plus sign can also indicate many other operations, depending on the mathematical system under consideration. Many algebraic structures, such as vector spaces and matrix rings, have some operation which is called, or is equivalent to, addition. It is though conventional to use the plus sign to only denote commutative operations.[15]

The symbol is also used in chemistry and physics. For more, see § Other uses.

Minus sign

The minus sign () has three main uses in mathematics:[16]

  1. The subtraction operator: a binary operator to indicate the operation of subtraction, as in 5 − 3 = 2. Subtraction is the inverse of addition.[1]
  2. The function whose value for any real or complex argument is the additive inverse of that argument. For example, if x = 3, then −x = −3, but if x = −3, then −x = +3. Similarly, −(−x) = x.
  3. A prefix of a numeric constant. When it is placed immediately before an unsigned number, the combination names a negative number, the additive inverse of the positive number that the numeral would otherwise name. In this usage, '−5' names a number the same way 'semicircle' names a geometric figure, with the caveat that 'semi' does not have a separate use as a function name.

In many contexts, it does not matter whether the second or the third of these usages is intended: −5 is the same number. When it is important to distinguish them, a raised minus sign (¯) is sometimes used for negative constants, as in elementary education, the programming language APL, and some early graphing calculators.[a]

All three uses can be referred to as "minus" in everyday speech, though the binary operator is sometimes read as "take away".[17] In American English nowadays, −5 (for example) is generally referred to as "negative five" though speakers born before 1950 often refer to it as "minus five". (Temperatures tend to follow the older usage; −5° is generally called "minus five degrees".)[18] Further, a few textbooks in the United States encourage −x to be read as "the opposite of x" or "the additive inverse of x"—to avoid giving the impression that −x is necessarily negative (since x itself may already be negative).[19]

In mathematics and most programming languages, the rules for the order of operations mean that −52 is equal to −25: Exponentiation binds more strongly than the unary minus, which binds more strongly than multiplication or division. However, in some programming languages (Microsoft Excel in particular), unary operators bind strongest, so in those cases −5^2 is 25, but 0−5^2 is −25.[20]

Similar to the plus sign, the minus sign is also used in chemistry and physics. (For more, see § Other uses below.)

Use in elementary education

Some elementary teachers use raised minus signs before numbers to disambiguate them from the operation of subtraction.[21] The same convention is also used in some computer languages. For example, subtracting −5 from 3 might be read as "positive three take away negative 5", and be shown as

3 − 5 becomes 3 + 5 = 8,

which can be read as:

+3 −1(5)

or even as

+3 − 5 becomes +3 + +5 = +8.

Use as a qualifier

When placed after a number, a plus sign can indicate an open range of numbers. For example, "18+" is commonly used as shorthand for "ages 18 and up" although "eighteen plus", for example, is now common usage.

In US grading systems, the plus sign indicates a grade one level higher and the minus sign a grade lower. For example, B− ("B minus") is one grade lower than B. In some occasions, this is extended to two plus or minus signs (e.g., A++ being two grades higher than A).[citation needed]

A common trend in branding, particularly with streaming video services, has been the use of the plus sign at the end of brand names, e.g. Google+, Disney+, Paramount+, and Apple TV+. Since the word "plus" can mean an advantage, or an additional amount of something, such "+" signs imply that a product offers extra features or benefits.

Positive and negative are sometimes abbreviated as +ve and −ve,[22] and on batteries and cell terminals are often marked with + and .

Mathematics

In mathematics the one-sided limit xa+ means x approaches a from the right (i.e., right-sided limit), and xa means x approaches a from the left (i.e., left-sided limit). For example, as x → 0+ but as x → 0.

When placed after special sets of numbers, plus and minus signs are used to indicate that only positive numbers and negative numbers are included, respectively. For example, is the set of all positive integers and is the set of all negative integers. In these cases, a subscript 0 may also be added to clarify that 0 is included.

Blood

Blood types are often qualified with a plus or minus to indicate the presence or absence of the Rh factor. For example, A+ means type A blood with the Rh factor present, while B− means type B blood with the Rh factor absent.

Music

In music, augmented chords are symbolized with a plus sign, although this practice is not universal (as there are other methods for spelling those chords). For example, "C+" is read "C augmented chord". Sometimes the plus is written as a superscript.

Uses in computing

As well as the normal mathematical usage, plus and minus signs may be used for a number of other purposes in computing.

Plus and minus signs are often used in tree view on a computer screen—to show if a folder is collapsed or not.

In some programming languages, concatenation of strings is written "a" + "b", and results in "ab".

In most programming languages, subtraction and negation are indicated with the ASCII hyphen-minus character, -. In APL a raised minus sign (here written using U+00AF ¯ MACRON) is used to denote a negative number, as in ¯3. While in J a negative number is denoted by an underscore, as in _5.

In C and some other computer programming languages, two plus signs indicate the increment operator and two minus signs a decrement; the position of the operator before or after the variable indicates whether the new or old value is read from it. For example, if x equals 6, then y = x++ increments x to 7 but sets y to 6, whereas y = ++x would set both x and y to 7. By extension, ++ is sometimes used in computing terminology to signify an improvement, as in the name of the language C++.

In regular expressions, + is often used to indicate "1 or more" in a pattern to be matched. For example, x+ means "one or more of the letter x". This is the Kleene plus notation. Hyphen-minus usually indicates a range ([A-Z] - any capital from 'A' to 'Z'), although it can stand for itself ([ABCDE-] any capital from 'A' to 'E' or '-').

There is no concept of negative zero in mathematics, but in computing −0 may have a separate representation from zero. In the IEEE floating-point standard, 1 / −0 is negative infinity () whereas 1 / 0 is positive infinity ().

+ is also used to denote added lines in diff output in the context format or the unified format.

Other uses

In physics, the use of plus and minus signs for different electrical charges was introduced by Georg Christoph Lichtenberg.

In chemistry, superscripted plus and minus signs are used to indicate an ion with a positive or negative charge of 1 (e.g., NH+
4
 
). If the charge is greater than 1, a number indicating the charge is written before the sign (as in SO2−
4
 
).

A plus sign prefixed to a telephone number is used to indicate the form used for International Direct Dialing.[23] Its precise usage varies by technology and national standards. In the International Phonetic Alphabet, subscripted plus and minus signs are used as diacritics to indicate advanced or retracted articulations of speech sounds.

The minus sign is also used as tone letter in the orthographies of Dan, Krumen, Karaboro, Mwan, Wan, Yaouré, , Nyabwa, and Godié.[24] The Unicode character used for the tone letter (U+02D7 ˗ MODIFIER LETTER MINUS SIGN) is different from the mathematical minus sign.

The plus sign sometimes represents /ɨ/ in the orthography of Huichol.[25]

In the algebraic notation used to record games of chess, the plus sign + is used to denote a move that puts the opponent into check, while a double plus ++ is sometimes used to denote double check. Combinations of the plus and minus signs are used to evaluate a move (+/−, +/=, =/+, −/+).

In linguistics, a superscript plus + sometimes replaces the asterisk, which denotes unattested linguistic reconstruction.

In botanical names, a plus sign denotes graft-chimaera.

In Catholicism, the plus sign before a last name denotes a Bishop, and a double plus is used to denote an Archbishop.

Unicode

- + −
hyphen-minus, plus, minus signs compared

Variants of the symbols have unique codepoints in Unicode:

  • U+002B + PLUS SIGN (&plus;)
  • U+2212 MINUS SIGN (&minus;)
  • U+002D - HYPHEN-MINUS
  • U+FE63 SMALL HYPHEN-MINUS
  • U+FE62 SMALL PLUS SIGN
  • U+FF0B FULLWIDTH PLUS SIGN
  • U+FF0D FULLWIDTH HYPHEN-MINUS
  • U+207A SUPERSCRIPT PLUS SIGN
  • U+207B SUPERSCRIPT MINUS
  • U+208A SUBSCRIPT PLUS SIGN
  • U+208B SUBSCRIPT MINUS
  • U+2064 INVISIBLE PLUS (a contiguity operator indicating addition)
  • U+29FA DOUBLE PLUS
  • U+29FB TRIPLE PLUS
  • U+29FE TINY
  • U+29FF ⧿ MINY
  • U+FB29 HEBREW LETTER ALTERNATIVE PLUS SIGN
  • U+2A27 PLUS SIGN WITH SUBSCRIPT TWO
  • U+2A22 PLUS SIGN WITH SMALL CIRCLE ABOVE
  • U+2A26 PLUS SIGN WITH TILDE BELOW
  • U+2A25 PLUS SIGN WITH DOT BELOW
  • U+2A24 PLUS SIGN WITH TILDE ABOVE
  • U+2A23 PLUS SIGN WITH CIRCUMFLEX ACCENT ABOVE
  • U+2A28 PLUS SIGN WITH BLACK TRIANGLE
  • U+2A29 MINUS SIGN WITH COMMA ABOVE
  • U+2A2A MINUS SIGN WITH DOT BELOW
  • U+2A2B MINUS SIGN WITH FALLING DOTS
  • U+2A2C MINUS SIGN WITH RISING DOTS
  • U+2A2D PLUS SIGN IN LEFT HALF CIRCLE
  • U+2A2E PLUS SIGN IN RIGHT HALF CIRCLE
  • U+2795 HEAVY PLUS SIGN
  • U+2796 HEAVY MINUS SIGN
  • U+293D TOP ARC ANTICLOCKWISE ARROW WITH PLUS
  • U+293C TOP ARC CLOCKWISE ARROW WITH MINUS
  • U+00B1 ± PLUS-MINUS SIGN (&plusmn;, &PlusMinus;, &pm;)
  • U+2213 MINUS-OR-PLUS SIGN (&MinusPlus;, &mnplus;, &mp;)
  • U+02D6 ˖ MODIFIER LETTER PLUS SIGN
  • U+02D7 ˗ MODIFIER LETTER MINUS SIGN
  • U+2238 DOT MINUS
  • U+2052 COMMERCIAL MINUS SIGN

Alternative minus signs

"÷" being used as a minus sign (not as a division sign) in an excerpt from an official Norwegian trading statement form called «Næringsoppgave 1» for the taxation year 2010

There is a commercial minus sign, , which is (or was) used in Germany and Scandinavia. The symbol ÷, still used in many Anglophone countries as a division sign, is (or was) used to denote subtraction in Scandinavia.[26]

The hyphen-minus symbol (-) is the form of hyphen most commonly used in digital documents. On most keyboards, it is the only character that resembles a minus sign or a dash so it is also used for these.[27] The name hyphen-minus derives from the original ASCII standard,[28] where it was called hyphen–(minus).[29] The character is referred to as a hyphen, a minus sign, or a dash according to the context where it is being used.

Alternative plus sign

A Jewish tradition that dates from at least the 19th century is to write plus using the symbol , to avoid the writing of a symbol + that could look like a Christian cross.[30][31] This practice was adopted into Israeli schools and is still commonplace today in elementary schools (including secular schools) but in fewer secondary schools.[31] It is also used occasionally in books by religious authors, but most books for adults use the international symbol +. Unicode has this symbol at position U+FB29 HEBREW LETTER ALTERNATIVE PLUS SIGN.[32]

See also

Notes

  1. ^ at least the early Texas Instruments models, including the TI-81 and TI-82

References

  1. ^ a b Weisstein, Eric W. "Subtraction". mathworld.wolfram.com. Archived from the original on 2020-09-14. Retrieved 2020-08-26.
  2. ^ Karpinski, Louis C. (1917). "Algebraical Developments Among the Egyptians and Babylonians". The American Mathematical Monthly. 24 (6): 257–265. doi:10.2307/2973180. JSTOR 2973180. MR 1518824.
  3. ^ The birth of symbols – Zdena Lustigova, Faculty of Mathematics and Physics Charles University, Prague Archived 2013-07-08 at archive.today
  4. ^ Ley, Willy (April 1965). "Symbolically Speaking". For Your Information. Galaxy Science Fiction. pp. 57–67.
  5. ^ Stallings, Lynn (May 2000). "A brief history of algebraic notation". School Science and Mathematics. 100 (5): 230–235. doi:10.1111/j.1949-8594.2000.tb17262.x. Retrieved 13 April 2009.
  6. ^ Sangster, Alan; Stoner, Greg; McCarthy, Patricia (2008). "The market for Luca Pacioli's Summa Arithmetica" (PDF). Accounting Historians Journal. 35 (1): 111–134 [p. 115]. doi:10.2308/0148-4184.35.1.111. S2CID 107010686. Archived (PDF) from the original on 2018-01-26. Retrieved 2012-04-29.
  7. ^ Cajori, Florian (1928). "Origin and meanings of the signs + and -". A History of Mathematical Notations, Vol. 1. The Open Court Company, Publishers.
  8. ^ Wright, D. Franklin; New, Bill D. (2000). Intermediate Algebra (4th ed.). Thomson Learning. p. 1. The minus sign or bar, — , is thought to be derived from the habit of early scribes of using a bar to represent the letter m
  9. ^ a b Widmann, Johannes (1489). "Behe[n]de vnd hubsche Rechenung auff allen kauffmanschafft". Leipzig : Konrad Kachelofen. p. 176. Archived from the original on 2022-05-03. Retrieved 2022-05-03.
  10. ^ a b Widmann, Johannes (1508). "Behend vnd hüpsch Rechnung vff allen Kauffmanschafften". Kolophon: Gedruck zů Pfhortzheim von Thoman Anßhelm. p. 122. Archived from the original on 2022-05-03. Retrieved 2022-05-03.
  11. ^ "plus". Oxford English Dictionary (Online ed.). Oxford University Press. (Subscription or participating institution membership required.)
  12. ^ Smith, D.E. (1951). History of Mathematics. Vol. 1. Courier Dover Publications. pp. 258, 330. ISBN 0486204308. {{cite book}}: ISBN / Date incompatibility (help)
  13. ^ "Earliest Uses of Symbols of Operation". Archived from the original on 2022-04-29. Retrieved 2022-05-03.
  14. ^ Cajori, Florian (2007), A History of Mathematical Notations, Cosimo, p. 164, ISBN 9781602066847.
  15. ^ Fraleigh, John B. (1989). A First Course in Abstract Algebra (4 ed.). United States: Addison-Wesley. p. 52. ISBN 0-201-52821-5.
  16. ^ Henri Picciotto (1990). The Algebra Lab. Creative Publications. p. 9. ISBN 978-0-88488-964-9.
  17. ^ "Subtraction". www.mathsisfun.com. Archived from the original on 2020-08-12. Retrieved 2020-08-26.
  18. ^ Schwartzman, Steven (1994). The words of mathematics. The Mathematical Association of America. p. 136. ISBN 9780883855119.
  19. ^ Wheeler, Ruric E. (2001). Modern Mathematics (11 ed.). p. 171.
  20. ^ "Microsoft Office Excel Calculation operators and precedence". Archived from the original on 2009-08-11. Retrieved 2009-07-29.
  21. ^ Gaskill, H.S.; Lopez, Robert J. (May 1978). "Let's bring back subtraction". International Journal of Mathematical Education in Science and Technology. 9 (2): 221–229. doi:10.1080/0020739780090211.
  22. ^ Castledine, George; Close, Ann (2009). Oxford Handbook of Adult Nursing. Oxford University Press. p. xvii. ISBN 9780191039676..
  23. ^ "Recommendation E.123: Notation for national and international telephone numbers, e-mail addresses and Web addresses". International Telecommunication Union. 2001. Archived from the original on 2021-05-05. Retrieved 2021-03-18.
  24. ^ Hartell, Rhonda L., ed. (1993), The Alphabets of Africa. Dakar: UNESCO and SIL.
  25. ^ Biglow, Brad Morris (2001). Ethno-Nationalist Politics and Cultural Preservation: Education and Bordered Identities Among the Wixaritari (Huichol) of Tateikita, Jalisco, Mexico (PDF) (PhD). University of Florida. p. 284. Archived (PDF) from the original on 2021-06-02. Retrieved 2021-05-29.
  26. ^ "6. Writing Systems and Punctuation". The Unicode Standard: Version 10.0 – Core Specification (PDF). Unicode Consortium. June 2017. p. 280, Obelus. Archived (PDF) from the original on 2021-10-04. Retrieved 2022-04-11.
  27. ^ Korpela, Jukka K. (2006). Unicode explained. O'Reilly. p. 382. ISBN 978-0-596-10121-3.
  28. ^ "3.1 General scripts" (PDF). Unicode Version 1.0 · Character Blocks. p. 30. Archived (PDF) from the original on 21 November 2021. Retrieved 10 December 2021. Loose vs. Precise Semantics. Some ASCII characters have multiple uses, either through ambiguity in the original standards or through accumulated reinterpretations of a limited codeset. For example, 27 hex is defined in ANSI X3.4 as apostrophe (closing single quotation mark; acute accent), and 2D hex as hyphen minus. In general, the Unicode standard provides the same interpretation for the equivalent code values, without adding to or subtracting from their semantics. The Unicode standard supplies unambiguous codes elsewhere for the most useful particular interpretations of these ASCII values; the corresponding unambiguous characters are cross-referenced in the character names list for this block. In a few cases, the Unicode standard indicates the generic interpretation of an ASCII code in the name of the corresponding Unicode character, for example U+0027 is APOSTROPHE-QUOTE'.
  29. ^ "American National Standard X3.4-1977: American Standard Code for Information Interchange" (PDF). National Institute of Standards and Technology. p. 10 (4.2 Graphic characters). Archived (PDF) from the original on 9 October 2022. Retrieved 10 December 2021.
  30. ^ Kaufmann Kohler (1901–1906). "Cross". In Cyrus Adler; et al. (eds.). Jewish Encyclopedia. Archived from the original on 2017-01-06. Retrieved 2017-02-12.
  31. ^ a b Christian-Jewish Dialogue: Theological Foundations By Peter von der Osten-Sacken (1986 – Fortress Press) Archived 2023-04-08 at the Wayback Machine ISBN 0-8006-0771-6 "In Israel the plus sign used in mathematics is represented by a horizontal stroke with a vertical hook instead of the sign otherwise used all over the world, because the latter is reminiscent of a cross." (Page 96)
  32. ^ Unicode U+FB29 reference page Archived 2009-01-26 at the Wayback Machine This form of the plus sign is also used on the control buttons at individual seats on board the El Al Israel Airlines aircraft.
  • The dictionary definition of plus sign at Wiktionary
  • The dictionary definition of minus sign at Wiktionary

If you don't care about the undefined case, you can remove the "|1 remove" at the end.

See also