Editing Subtract 0 You are not logged in. The rich text editor does not work with JavaScript switched off. Please either enable it in your browser options, or visit your preferences to switch to the old MediaWiki editor The '''subtract''' operator is an [[Arithmetic Operators|arithmetic operator]] which subtracts a [[Numbers|number]] object from another. Its token is named '''SUBTRACTION'''. == Phrases == * {{code|operator|minus}} * {{code|operator|without}} * {{code|operator|the difference between}} ** {{code|operator|and}} * {{code|operator|subtract}} ** {{code|operator|from}} === Infix === {{See Also/small|Infix notation}} Infix notation can be achieved using the phrases {{Code|operator|minus}} or {{Code|operator|without}}. Its [[FDS]] is {{codeblock|{{tag|value|number}}{{tag|whitespace}}{{Code|operator|[minus/without]}}{{tag|whitespace}}{{tag|value|number}}}} ==== Example ==== {{codeblock|{{Code|keyword|I wrote}}{{Code|whitespace| }}{{Code|type|the number}}{{Code|whitespace| }}{{Code|literal|13}}{{Code|whitespace| }}{{Code|operator|minus}}{{Code|whitespace| }}{{Code|type|the number}}{{Code|whitespace| }}{{Code|literal|10}}{{Code|punctuation|.}}}} This [[Print|prints]] {{Code|literal|3}}. Its Java equivalent is as follows: {{codeblock|<SOURCE LANG=java>System.out.println((double)13 - (double)10);</SOURCE>}} === Prefix === {{See Also/small|Prefix notation}} Prefix notation can be achieved using the phrase {{Code|operator|subtract}} or {{Code|operator|the difference between}} and the infix separator {{Code|operator|from}} or {{Code|operator|and}}. Its [[FDS]] is {{codeblock|{{Code|operator|[subtract/the difference between]}}{{tag|whitespace}}{{tag|value|number}}{{tag|whitespace}}{{Code|operator|[and/from]}}{{tag|whitespace}}{{tag|value|number}} ==== Example ==== {{codeblock|{{Code|keyword|I wrote}}{{Code|whitespace| }}{{Code|operator|the difference between}}{{Code|whitespace| }}{{Code|type|the number}}{{Code|whitespace| }}{{Code|literal|13}}{{Code|whitespace| }}{{Code|operator|and}}{{Code|whitespace| }}{{Code|type|the number}}{{Code|whitespace| }}{{Code|literal|10}}{{Code|punctuation|.}}}} This has the same effect as the previous example. Note that this can introduce some ambiguity. For instance: {{codeblock|{{code|keyword|I wrote}}{{code|whitespace| }}{{code|operator|the difference between}}{{code|whitespace| }}{{code|literal|10}}{{code|operator|and}}{{code|whitespace| }}{{code|literal|2}}{{code|whitespace| }}{{code|operator|and}}{{code|literal|5}}{{code|punctuation|.}}}} {{output|13}} One might expect the output to be 3, because they expect its Java equivalent to be <SOURCE LANG=Java>10 - 2 - 5</SOURCE>, but its Java equivalent is actually <SOURCE LANG=Java>10 - 2 + 5</SOURCE>. This is because the {{code|operator|the difference between}} and {{code|operator|subtract}} operators only have '''one''' partner infix operator, {{code|operator|and}} and {{code|operator|from}}, respectively. This means that {{codeblock|{{code|keyword|I wrote}}{{code|whitespace| }}{{code|operator|the difference between}}{{code|whitespace| }}{{code|literal|10}}{{code|operator|and}}{{code|whitespace| }}{{code|literal|2}} is processed alone, and returns {{code|literal|8}}. Then, {{code|literal|8}}{{code|whitespace| }}{{code|operator|and}}{{code|whitespace| }}{{code|literal|5}} is processed as [[addition]], returning {{code|literal|13}}. This is because using an {{code|operator|and}} as an operator without any prefix context denotes addition. There is no prefix context for the second {{code|operator|and}} because the first one has already been processed. == Decrement == {{Main/small|Decrement}} The decrement operator is a special case of subtraction, and subtracts the fixed value {{Code|literal|1}} from a '''variable''' and cannot be used on literals. == See Also == * [[Prefix notation]] * [[Infix notation]] * [[Decrement]] {{Navbox/Phrases}} {{stub}} Loading editor Below are some commonly used wiki markup codes. Simply click on what you want to use and it will appear in the edit box above. Insert: – — … ° ≈ ≠ ≤ ≥ ± − × ÷ ← → · § Sign your username: ~~~~ Wiki markup: {{}} | [] [[]] [[Category:]] #REDIRECT [[]] <s></s> <sup></sup> <sub></sub> <code></code> <blockquote></blockquote> <ref></ref> {{Reflist}} <references/> <includeonly></includeonly> <noinclude></noinclude> {{DEFAULTSORT:}} <nowiki></nowiki> <!-- --> <span class="plainlinks"></span> Symbols: ~ | ¡ ¿ † ‡ ↔ ↑ ↓ • ¶ # ¹ ² ³ ½ ⅓ ⅔ ¼ ¾ ⅛ ⅜ ⅝ ⅞ ∞ ‘ “ ’ ” «» ¤ ₳ ฿ ₵ ¢ ₡ ₢ $ ₫ ₯ € ₠ ₣ ƒ ₴ ₭ ₤ ℳ ₥ ₦ № ₧ ₰ £ ៛ ₨ ₪ ৳ ₮ ₩ ¥ ♠ ♣ ♥ ♦ View this template This field is a spam trap. DO NOT fill it in! Edit summary Preview Mobile Desktop Show changes