diff options
author | Olivier Hallot <olivier.hallot@libreoffice.org> | 2023-06-23 21:14:25 -0300 |
---|---|---|
committer | Olivier Hallot <olivier.hallot@libreoffice.org> | 2023-06-24 13:10:39 +0200 |
commit | 9615cb2ed0275615f853c027087fa5ef46f72eae (patch) | |
tree | 785f6542097423689a04addd25a968b96b32814e | |
parent | 5d7fd5dd8910f3d7bc98c8a3d452102d133f4ffa (diff) |
tdf#156029 operator precedence in Calc
Change-Id: If6410c72b4b085f3012e926c9a0dc2175d4ce2af
Reviewed-on: https://gerrit.libreoffice.org/c/help/+/153542
Tested-by: Jenkins
Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
-rw-r--r-- | source/text/scalc/01/04060199.xhp | 176 |
1 files changed, 145 insertions, 31 deletions
diff --git a/source/text/scalc/01/04060199.xhp b/source/text/scalc/01/04060199.xhp index d7c050fb11..30648afb93 100644 --- a/source/text/scalc/01/04060199.xhp +++ b/source/text/scalc/01/04060199.xhp @@ -24,18 +24,20 @@ </topic> </meta> <body> -<bookmark branch="index" id="bm_id3156445"><bookmark_value>formulas; operators</bookmark_value> +<bookmark branch="index" id="bm_id3156445"> +<bookmark_value>operators; in spreadsheet formulas</bookmark_value> +<bookmark_value>formulas; operators</bookmark_value> <bookmark_value>operators; formula functions</bookmark_value> +</bookmark><comment>mw added 7 new index entries</comment> +<h1 id="hd_id3156445">Operators in $[officename] Calc</h1> +<paragraph role="paragraph" id="par_id3155812">You can use the following operators in $[officename] Calc:</paragraph> +<bookmark branch="index" id="bm_id891687563561282"> +<bookmark_value>arithmetical operators</bookmark_value> <bookmark_value>division sign, see also operators</bookmark_value> <bookmark_value>multiplication sign, see also operators</bookmark_value> <bookmark_value>minus sign, see also operators</bookmark_value> <bookmark_value>plus sign, see also operators</bookmark_value> -<bookmark_value>text operators</bookmark_value> -<bookmark_value>comparisons;operators in Calc</bookmark_value> -<bookmark_value>arithmetical operators</bookmark_value> -<bookmark_value>reference operators</bookmark_value> -</bookmark><comment>mw added 7 new index entries</comment><h1 id="hd_id3156445">Operators in $[officename] Calc</h1> -<paragraph role="paragraph" id="par_id3155812">You can use the following operators in $[officename] Calc:</paragraph> +</bookmark> <h2 id="hd_id3153066">Arithmetical Operators</h2> <paragraph role="paragraph" id="par_id3148601">These operators return numerical results.</paragraph> <table id="tbl_id3151240"> @@ -52,7 +54,7 @@ </tablerow> <tablerow> <tablecell> -<paragraph role="tablecontent" id="par_id3149126">+ (Plus)</paragraph> + <paragraph role="tablecontent" localize="false" id="par_id3149126">+</paragraph> </tablecell> <tablecell> <paragraph role="tablecontent" id="par_id3150892">Addition</paragraph> @@ -63,7 +65,7 @@ </tablerow> <tablerow> <tablecell> -<paragraph role="tablecontent" id="par_id3159204">- (Minus)</paragraph> + <paragraph role="tablecontent" localize="false" id="par_id3159204">-</paragraph> </tablecell> <tablecell> <paragraph role="tablecontent" id="par_id3145362">Subtraction</paragraph> @@ -74,7 +76,7 @@ </tablerow> <tablerow> <tablecell> -<paragraph role="tablecontent" id="par_id3153808">- (Minus)</paragraph> + <paragraph role="tablecontent" localize="false" id="par_id3153808">-</paragraph> </tablecell> <tablecell> <paragraph role="tablecontent" id="par_id3151193">Negation</paragraph> @@ -85,7 +87,7 @@ </tablerow> <tablerow> <tablecell> -<paragraph role="tablecontent" id="par_id3149873">* (asterisk)</paragraph> + <paragraph role="tablecontent" localize="false" id="par_id3149873">*</paragraph> </tablecell> <tablecell> <paragraph role="tablecontent" id="par_id3147504">Multiplication</paragraph> @@ -96,7 +98,7 @@ </tablerow> <tablerow> <tablecell> -<paragraph role="tablecontent" id="par_id3151341">/ (Slash)</paragraph> + <paragraph role="tablecontent" localize="false" id="par_id3151341">/</paragraph> </tablecell> <tablecell> <paragraph role="tablecontent" id="par_id3159260">Division</paragraph> @@ -107,7 +109,7 @@ </tablerow> <tablerow> <tablecell> -<paragraph role="tablecontent" id="par_id3156396">% (Percent)</paragraph> + <paragraph role="tablecontent" localize="false" id="par_id3156396">%</paragraph> </tablecell> <tablecell> <paragraph role="tablecontent" id="par_id3150372">Percent</paragraph> @@ -118,7 +120,7 @@ </tablerow> <tablerow> <tablecell> -<paragraph role="tablecontent" id="par_id3149722">^ (Caret)</paragraph> + <paragraph role="tablecontent" localize="false" id="par_id3149722">^</paragraph> </tablecell> <tablecell> <paragraph role="tablecontent" id="par_id3159127">Exponentiation</paragraph> @@ -131,6 +133,10 @@ <note id="par_id881623862728559">Prefix "-" (negation) has a higher precedence than "^" (exponentiation). For example -3^2 equals 9, which is the square of a negative number.</note> +<bookmark branch="index" id="bm_id481687564343986"> +<bookmark_value>operators;comparison</bookmark_value> +<bookmark_value>comparisons;operators in Calc</bookmark_value> +</bookmark> <h2 id="hd_id3152981">Comparative operators</h2> <paragraph role="paragraph" id="par_id3157902">These operators return either true or false.</paragraph> <table id="tbl_id3148725"> @@ -147,7 +153,7 @@ </tablerow> <tablerow> <tablecell> -<paragraph role="tablecontent" id="par_id3148888">= (equal sign)</paragraph> +<paragraph role="tablecontent" localize="false" id="par_id3148888">=</paragraph> </tablecell> <tablecell> <paragraph role="tablecontent" id="par_id3154845">Equal</paragraph> @@ -158,18 +164,18 @@ </tablerow> <tablerow> <tablecell> -<paragraph role="tablecontent" id="par_id3154807">> (Greater than)</paragraph> + <paragraph role="tablecontent" localize="false" id="par_id3154807">></paragraph> </tablecell> <tablecell> <paragraph role="tablecontent" id="par_id3148580">Greater than</paragraph> </tablecell> <tablecell> -<paragraph role="tablecontent" id="par_id3145138" localize="false">A1>B1</paragraph> + <paragraph role="tablecontent" id="par_id3145138" localize="false">A1>B1</paragraph> </tablecell> </tablerow> <tablerow> <tablecell> -<paragraph role="tablecontent" id="par_id3149507">< (Less than)</paragraph> +<paragraph role="tablecontent" localize="false" id="par_id3149507"><</paragraph> </tablecell> <tablecell> <paragraph role="tablecontent" id="par_id3150145">Less than</paragraph> @@ -180,7 +186,7 @@ </tablerow> <tablerow> <tablecell> -<paragraph role="tablecontent" id="par_id3153078">>= (Greater than or equal to)</paragraph> + <paragraph role="tablecontent" localize="false" id="par_id3153078">>=</paragraph> </tablecell> <tablecell> <paragraph role="tablecontent" id="par_id3150866">Greater than or equal to</paragraph> @@ -191,7 +197,7 @@ </tablerow> <tablerow> <tablecell> -<paragraph role="tablecontent" id="par_id3153004"><= (Less than or equal to)</paragraph> + <paragraph role="tablecontent" localize="false" id="par_id3153004"><=</paragraph> </tablecell> <tablecell> <paragraph role="tablecontent" id="par_id3150335">Less than or equal to</paragraph> @@ -202,7 +208,7 @@ </tablerow> <tablerow> <tablecell> -<paragraph role="tablecontent" id="par_id3157994"><> (Inequality)</paragraph> + <paragraph role="tablecontent" localize="false" id="par_id3157994"><></paragraph> </tablecell> <tablecell> <paragraph role="tablecontent" id="par_id3150019">Inequality</paragraph> @@ -212,6 +218,10 @@ </tablecell> </tablerow> </table> +<bookmark branch="index" id="bm_id3157975"> +<bookmark_value>text operators</bookmark_value> +<bookmark_value>text concatenation</bookmark_value> +</bookmark> <h2 id="hd_id3145241">Text operators</h2> <paragraph role="paragraph" id="par_id3155438">The operator combines separate texts into one text.</paragraph> <table id="tbl_id3156061"> @@ -228,18 +238,22 @@ </tablerow> <tablerow> <tablecell> -<paragraph role="tablecontent" id="par_id3148769">& (And)</paragraph> + <paragraph role="tablecontent" localize="false" id="par_id3148769">&</paragraph> </tablecell> <tablecell> -<bookmark branch="index" id="bm_id3157975"><bookmark_value>text concatenation AND</bookmark_value> -</bookmark> -<paragraph role="tablecontent" id="par_id3157975">text concatenation AND</paragraph> +<paragraph role="tablecontent" id="par_id3157975">text concatenation</paragraph> </tablecell> <tablecell> <paragraph role="tablecontent" id="par_id3157993">"Sun" & "day" is "Sunday"</paragraph> </tablecell> </tablerow> </table> +<bookmark branch="index" id="bm_id291687563892759"> +<bookmark_value>reference operators</bookmark_value> +<bookmark_value>intersection reference operator</bookmark_value> +<bookmark_value>union reference operator</bookmark_value> +<bookmark_value>range operator</bookmark_value> +</bookmark> <section id="referenceoperators"> <h2 id="hd_id3153550">Reference operators</h2> <paragraph role="paragraph" id="par_id3149024">These operators return a cell range of zero, one or more cells.</paragraph> @@ -253,12 +267,12 @@ <paragraph role="tablehead" id="par_id3152822">Name</paragraph> </tablecell> <tablecell> - <paragraph role="tablehead" id="par_id521599494740206">Example</paragraph> +<paragraph role="tablehead" id="par_id521599494740206">Example</paragraph> </tablecell> </tablerow> <tablerow> <tablecell> -<paragraph role="tablecontent" id="par_id3156257">: (Colon)</paragraph> +<paragraph role="tablecontent" localize="false" id="par_id3156257">:</paragraph> </tablecell> <tablecell> <paragraph role="tablecontent" id="par_id3153924">Range</paragraph> @@ -269,11 +283,9 @@ </tablerow> <tablerow> <tablecell> -<paragraph role="tablecontent" id="par_id3152592">! (Exclamation point)</paragraph> +<paragraph role="tablecontent" localize="false" id="par_id3152592">!</paragraph> </tablecell> <tablecell> -<bookmark branch="index" id="bm_id3150606"><bookmark_value>intersection operator</bookmark_value> -</bookmark> <paragraph role="tablecontent" id="par_id3150606">Intersection</paragraph> </tablecell> <tablecell> @@ -283,7 +295,7 @@ </tablerow> <tablerow> <tablecell> -<paragraph role="tablecontent" id="par_id4003723">~ (Tilde)</paragraph> +<paragraph role="tablecontent" localize="false" id="par_id4003723">~</paragraph> </tablecell> <tablecell> <paragraph role="tablecontent" id="par_id838953">Concatenation or union</paragraph> @@ -297,5 +309,107 @@ </table> <note id="par_id181890">A reference list is not allowed inside an array expression.</note> </section> +<bookmark xml-lang="en-US" branch="index" id="bm_id311687563684141"> + <bookmark_value>operators;precedence of</bookmark_value> +</bookmark> +<h2 id="hd_id981687562294437">Operator precedence</h2> +<paragraph role="paragraph" id="par_id271687562351999">Associativity and precedence of operators, from highest to lowest precedence.</paragraph> +<table id="tbl_precedence"> + <tablerow> + <tablecell><paragraph role="tablehead" id="par_id461687561515440">Associativity</paragraph> + </tablecell> + <tablecell><paragraph role="tablehead" id="par_id801687561518810">Operator(s)</paragraph> + </tablecell> + <tablecell><paragraph role="tablehead" id="par_id521687561523649">Comments</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell><paragraph role="tablecontent" id="par_id611687561527049">left</paragraph> + </tablecell> + <tablecell><paragraph role="tablecontent" localize="false" id="par_id561687561531281">:</paragraph> + </tablecell> + <tablecell><paragraph role="tablecontent" id="par_id651687561534345">Range.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell><paragraph role="tablecontent" id="par_id961687561539434">left</paragraph> + </tablecell> + <tablecell><paragraph role="tablecontent" localize="false" id="par_id301687561544010">!</paragraph> + </tablecell> + <tablecell><paragraph role="tablecontent" id="par_id721687561546778">Reference intersection (A1:C4!B1:B5 is B1:B4).</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell><paragraph role="tablecontent" id="par_id741687561555251">left</paragraph> + </tablecell> + <tablecell><paragraph role="tablecontent" localize="false" id="par_id901687561558641">~</paragraph> + </tablecell> + <tablecell><paragraph role="tablecontent" id="par_id121687561561898">Reference union.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell><paragraph role="tablecontent" id="par_id731687561708790">right</paragraph></tablecell> + <tablecell><paragraph role="tablecontent" localize="false" id="par_id61687561711845">+,-</paragraph> + </tablecell> + <tablecell><paragraph role="tablecontent" id="par_id721687561715845">Prefix unary operators, e.g., -5 or -A1. Note that these have a different precedence than add and subtract.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell><paragraph role="tablecontent" id="par_id171687561719559">left</paragraph> + </tablecell> + <tablecell><paragraph role="tablecontent" localize="false" id="par_id561687561722949">%</paragraph> + </tablecell> + <tablecell><paragraph role="tablecontent" id="par_id791687561727359">Postfix unary operator % (divide by 100). Note that this is legal with expressions, for example, B1%.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell><paragraph role="tablecontent" id="par_id681687561735190">left</paragraph> + </tablecell> + <tablecell><paragraph role="tablecontent" localize="false" id="par_id781687561738654">^</paragraph> + </tablecell> + <tablecell><paragraph role="tablecontent" id="par_id321687561741773">Power (2^3 is 8).</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell><paragraph role="tablecontent" id="par_id321687561745015">left</paragraph> + </tablecell> + <tablecell><paragraph role="tablecontent" localize="false" id="par_id121687561747982">*,/</paragraph> + </tablecell> + <tablecell><paragraph role="tablecontent" id="par_id431687561758704">Multiply, divide.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell><paragraph role="tablecontent" id="par_id931687561762278">left</paragraph> + </tablecell> + <tablecell><paragraph role="tablecontent" localize="false" id="par_id241687561766047">+,-</paragraph> + </tablecell> + <tablecell><paragraph role="tablecontent" id="par_id731687561770325">Binary operations add, subtract. Note that unary (prefix) + and - have a different precedence.</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell><paragraph role="tablecontent" id="par_id541687561818607">left</paragraph> + </tablecell> + <tablecell><paragraph role="tablecontent" localize="false" id="par_id421687561821896">&</paragraph> + </tablecell> + <tablecell><paragraph role="tablecontent" id="par_id391687561825288">Binary operation string concatenation. Note that unary (prefix) + and - have a different precedence. Note that "&" shall be escaped when included in an XML document</paragraph> + </tablecell> + </tablerow> + <tablerow> + <tablecell><paragraph role="tablecontent" id="par_id921687561831376">left</paragraph> + </tablecell> + <tablecell><paragraph role="tablecontent" localize="false" id="par_id41687561835121">=, <>, <, <=,<br/>>, >=</paragraph> + </tablecell> + <tablecell><paragraph role="tablecontent" id="par_id631687561838545">Comparison operators equal to, not equal to, less than, less than or equal to, greater than, greater than or equal to</paragraph> + </tablecell> + </tablerow> +</table> +<note id="par_id241687561247336">Prefix "-" has a higher precedence than "^", "^" is left-associative, and +reference intersection has a higher precedence than reference union.</note> +<note id="par_id941687561277896">Prefix "+" and "-" are defined to be right-associative. However, note that typical +applications which implement at most the operators defined in this specification (as specified) may implement them as left-associative, because the calculated results will be identical.</note> +<note id="par_id411687561295059">Precedence can be overridden by using parentheses, so "=2+3*4" computes to 14 but "=(2+3)*4" computes 20.</note> +<section id="relatedtopics"> + <paragraph role="paragraph" id="par_id661687565493405"><link href="OpenDocument/v1.3/os/part4-formula/OpenDocument-v1.3-os-part4-formula.html#Operators">OpenDocument v1.3 part4, Formula Operators</link></paragraph> +</section> </body> </helpdocument> |